基于javaweb+mysql的springboot办公erp管理系统(java+springboot+easyui+maven+mysql+html)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot办公erp管理系统(java+springboot+easyui+maven+mysql+html)
项目介绍
系统主要功能包括: 首页 零售管理:零售出库、零售退货; 采购管理:采购订单、采购入库、采购退货; 销售管理:销售订单、销售出库、销售退货; 仓库管理:其它入库、其它出库、调拨出库、组装单、拆卸单; 财务管理:收入单、支出单、收款单、付款单、转账单、收预付款; 报表查询:库存状况、结算账户、进货统计、销售统计、入库明细、出库明细、入库汇总、出库汇总、客户对账、供应商对账、库存预警; 商品管理:商品类别、商品信息、计量单位、序列号; 基本资料:供应商信息、客户信息、会员信息、仓库信息、收支项目、结算账户、经手人管理;
系统管理:角色管理、机构管理、用户管理、日志管理、系统配置;
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7或8.0版本;
6.是否Maven项目:是;
技术栈
-
核心框架:SpringBoot 2.0.0 * 持久层框架:Mybatis 1.3.2 * 日志管理:Log4j 2.10.0 * JS框架:Jquery 1.8.0 * UI框架: EasyUI 1.3.5 * 模板框架: AdminLTE 2.4.0
-
项目管理框架: Maven 3.2.3
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.properties配置文件中的数据库配置改为自己的配置; 4. 运行com.jsh.erp包中的ErpApplication类,启动项目。(使用SpringBoot的启动方式) 5. 浏览器地址访问登录页面http://localhost:8080/login.html 默认管理员账号:admin,管理员账号一些特殊模块不具有修改权限,建议使用普通账号:jsh,密码都为123456
List<DepotHeadVo4InDetail> list = depotHeadService.findByAll(beginTime, endTime, type, pid, dids, oId, (currentPage-1)*pageSize, pageSize);
int total = depotHeadService.findByAllCount(beginTime, endTime, type, pid, dids, oId);
map.put("total", total);
//存放数据json数组
if (null != list) {
for (DepotHeadVo4InDetail dhd : list) {
resList.add(dhd);
}
}
map.put("rows", resList);
res.code = 200;
res.data = map;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 入库出库统计接口
* @param currentPage
* @param pageSize
* @param oId
* @param pid
* @param dids
* @param beginTime
* @param endTime
* @param type
* @param request
* @return
*/
@GetMapping(value = "/findInOutMaterialCount")
public BaseResponseInfo findInOutMaterialCount(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize,
@RequestParam("organId") Integer oId,
@RequestParam("projectId") Integer pid,
@RequestParam("depotIds") String dids,
@RequestParam("beginTime") String beginTime,
@RequestParam("endTime") String endTime,
@RequestParam("type") String type,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
item.put("MaterialColor", diEx.getMColor());
item.put("MaterialUnit", diEx.getMaterialUnit());
item.put("UName", diEx.getUName());
item.put("OutSum", OutSumRetail.add(OutSum));
item.put("InSum", InSumRetail.add(InSum));
item.put("OutSumPrice", OutSumRetailPrice.add(OutSumPrice));
item.put("InSumPrice", InSumRetailPrice.add(InSumPrice));
item.put("OutInSumPrice",OutInSumPrice);//实际销售金额
dataArray.add(item);
}
}
map.put("rows", dataArray);
res.code = 200;
res.data = map;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 获取单位
* @param materialUnit
* @param uName
* @return
*/
public String getUName(String materialUnit, String uName) {
String unitName = null;
if(!StringUtil.isEmpty(materialUnit)) {
unitName = materialUnit;
} else if(!StringUtil.isEmpty(uName)) {
unitName = uName.substring(0,uName.indexOf(","));
}
return unitName;
}
/**
* 获取单价
* @param presetPriceOne
* @param priceStrategy
* @return
*/
public BigDecimal getUnitPrice(BigDecimal presetPriceOne, String priceStrategy) {
BigDecimal unitPrice = BigDecimal.ZERO;
if(presetPriceOne != null) {
DecimalFormat df = new DecimalFormat("#.00");
unitPrice = new BigDecimal(df.format(presetPriceOne));
List<DepotItemStockWarningCount> list = null;
try{
list =depotItemMapperEx.findStockWarningCount( offset, rows, pid);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int findStockWarningCountTotal(Integer pid) {
int result = 0;
try{
result =depotItemMapperEx.findStockWarningCountTotal(pid);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
/**
* 统计该商品已分批出库的总数量-用于订单
* @param mid
* @param headerId
* @return
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public BigDecimal getFinishNumber(Long mid, Long headerId) {
DepotHead depotHead =depotHeadMapper.selectByPrimaryKey(headerId);
String linkNumber = depotHead.getLinknumber(); //关联单号
BigDecimal count = depotItemMapperEx.getFinishNumber(mid, linkNumber);
return count;
}
/**
* 库存统计
* @param depotId
* @param mId
* @param beginTime
* @param endTime
* @return
*/
public BigDecimal getStockByParam(Long depotId, Long mId, String beginTime, String endTime, Long tenantId){
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParam(depotId, mId, beginTime, endTime, tenantId);
BigDecimal intNum = stockObj.getInNum();
BigDecimal outNum = stockObj.getOutNum();
return intNum.subtract(outNum);
}
/**
* 入库统计
public List<DepotItemVo4WithInfoEx> findByAll(String headIds, String materialIds, Integer offset, Integer rows)throws Exception {
List<DepotItemVo4WithInfoEx> list =null;
try{
list = depotItemMapperEx.findByAll(headIds, materialIds, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public int findByAllCount(String headIds, String materialIds)throws Exception {
int result=0;
try{
result = depotItemMapperEx.findByAllCount(headIds, materialIds);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public BigDecimal buyOrSale(String type, String subType, Long MId, String MonthTime, String sumType) throws Exception{
BigDecimal result= BigDecimal.ZERO;
try{
if (SUM_TYPE.equals(sumType)) {
result= depotItemMapperEx.buyOrSaleNumber(type, subType, MId, MonthTime, sumType);
} else {
result= depotItemMapperEx.buyOrSalePrice(type, subType, MId, MonthTime, sumType);
}
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
/**
* 统计采购或销售的总金额
* @param type
* @param subType
* @param MonthTime
* @return
* @throws Exception
*/
public BigDecimal inOrOutPrice(String type, String subType, String MonthTime) throws Exception{
BigDecimal result= BigDecimal.ZERO;
try{
result = depotItemMapperEx.inOrOutPrice(type, subType, MonthTime);
List<User> dataList = userService.getUser();
if(dataList!=null) {
data.put("userList", dataList);
}
res.code = 200;
res.data = data;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取失败";
}
return res;
}
/**
* create by: cjl
* description:
* 查询分页用户列表
* @Param: pageSize
* @Param: currentPage
* @Param: search
* @return java.lang.String
*/
@GetMapping(value = "/getUserList")
public String getUserList(@RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize,
@RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage,
@RequestParam(value = Constants.SEARCH, required = false) String search)throws Exception {
Map<String, Object> parameterMap = new HashMap<String, Object>();
//查询参数
JSONObject obj= JSON.parseObject(search);
Set<String> key= obj.keySet();
for(String keyEach: key){
parameterMap.put(keyEach,obj.getString(keyEach));
}
PageQueryInfo queryInfo = new PageQueryInfo();
Map<String, Object> objectMap = new HashMap<String, Object>();
if (pageSize == null || pageSize <= 0) {
pageSize = BusinessConstants.DEFAULT_PAGINATION_PAGE_SIZE;
}
if (currentPage == null || currentPage <= 0) {
}
if(mList.size()>1){
//查询到的数据条数大于1,编号已存在
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE,
ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG);
}
if(mc.getId()==null){
//新增时,编号已存在
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE,
ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG);
}
/**
* 包装类型用equals来比较
* */
if(mc.getId().equals(mList.get(0).getId())){
//修改时,相同编号,id不同
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE,
ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG);
}
}
/**
* create by: qiankunpingtai
* website:https://qiankunpingtai.cn
* description:
* 正常删除,要考虑数据完整性,进行完整性校验
* @Param: ids
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteMaterialCategoryByIdsNormal(String ids) throws Exception {
/**
* 校验
* 1、产品表 jsh_material
* 2、产品类型表 jsh_materialcategory
* 是否有相关数据
* */
int deleteTotal=0;
if(StringUtils.isEmpty(ids)){
return deleteTotal;
}
String [] idArray=ids.split(",");
/**
* 校验产品表 jsh_material
* */
List<Material> materialList=null;
try{
materialList= materialMapperEx.getMaterialListByCategoryIds(idArray);
}catch(Exception e){
JshException.readFail(logger, e);
}
if(materialList!=null&&materialList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,CategoryIds[{}]",
}
accountItem.setRemark(tempUpdatedJson.getString("Remark"));
this.updateAccountItemWithObj(accountItem);
}
}
return null;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccountItemByIds(String ids) throws Exception{
logService.insertLog("财务明细",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
int result=0;
try{
result = accountItemMapperEx.batchDeleteAccountItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
}
package com.jsh.erp.service.accountHead;
*/
public BigDecimal getStockByParam(Long depotId, Long mId, String beginTime, String endTime, Long tenantId){
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParam(depotId, mId, beginTime, endTime, tenantId);
BigDecimal intNum = stockObj.getInNum();
BigDecimal outNum = stockObj.getOutNum();
return intNum.subtract(outNum);
}
/**
* 入库统计
* @param depotId
* @param mId
* @param beginTime
* @param endTime
* @return
*/
public BigDecimal getInNumByParam(Long depotId, Long mId, String beginTime, String endTime, Long tenantId){
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParam(depotId, mId, beginTime, endTime, tenantId);
return stockObj.getInNum();
}
/**
* 出库统计
* @param depotId
* @param mId
* @param beginTime
* @param endTime
* @return
*/
public BigDecimal getOutNumByParam(Long depotId, Long mId, String beginTime, String endTime, Long tenantId){
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParam(depotId, mId, beginTime, endTime, tenantId);
return stockObj.getOutNum();
}
}
package com.jsh.erp.service.depotHead;
Map<String, Object> map = new HashMap<String, Object>();
String message = "成功";
try {
Date date = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM");
String dateString = formatter.format(date);
List<String> list = Tools.getSixMonth(dateString);
map.put("monthList", list);
List<BigDecimal> buyPriceList = new ArrayList<BigDecimal>();
for(String month: list) {
BigDecimal outPrice = depotItemService.inOrOutPrice("入库", "采购", month);
BigDecimal inPrice = depotItemService.inOrOutPrice("出库", "采购退货", month);
buyPriceList.add(outPrice.subtract(inPrice));
}
map.put("buyPriceList", buyPriceList);
List<BigDecimal> salePriceList = new ArrayList<BigDecimal>();
for(String month: list) {
BigDecimal outPrice = depotItemService.inOrOutPrice("出库", "销售", month);
BigDecimal inPrice = depotItemService.inOrOutPrice("入库", "销售退货", month);
salePriceList.add(outPrice.subtract(inPrice));
}
map.put("salePriceList", salePriceList);
res.code = 200;
res.data = map;
} catch (Exception e) {
e.printStackTrace();
message = "统计失败";
res.code = 500;
}
return res;
}
}
package com.jsh.erp.service.depotItem;
dataArray.add(item);
}
}
arr = dataArray;
} catch(Exception e){
e.printStackTrace();
}
return arr;
}
/**
* 查找会员信息-下拉框
* @param request
* @return
*/
@PostMapping(value = "/findBySelect_retail")
public JSONArray findBySelectRetail(HttpServletRequest request)throws Exception {
JSONArray arr = new JSONArray();
try {
List<Supplier> supplierList = supplierService.findBySelectRetail();
JSONArray dataArray = new JSONArray();
if (null != supplierList) {
for (Supplier supplier : supplierList) {
JSONObject item = new JSONObject();
item.put("id", supplier.getId());
//客户名称
item.put("supplier", supplier.getSupplier());
item.put("advanceIn", supplier.getAdvancein()); //预付款金额
dataArray.add(item);
}
}
arr = dataArray;
} catch(Exception e){
e.printStackTrace();
}
return arr;
}
/**
* 根据id查找信息
* @param supplierId
* @param request
* @return
*/
@GetMapping(value = "/findById")
public BaseResponseInfo findById(@RequestParam("supplierId") Long supplierId,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
try {
JSONArray dataArray = new JSONArray();
List<Supplier> dataList = supplierService.findById(supplierId);
if (null != dataList) {
Runtime r = Runtime.getRuntime();
String[] cmdArray = new String[]{"cmd.exe", "/c", viewFilePath};
try {
r.exec(cmdArray);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 判断字符串中是否含有中文
*
* @param str
* @return
*/
public static boolean isContainsChinese(String str) {
return Pattern.compile("[\u4e00-\u9fa5]").matcher(str).matches();
}
/**
* 过滤html文件中的文本
*
* @param content
* @return过滤后的文本
*/
public static String filterText(String content) {
return content.replace("/<(?:.|\\s)*?>/g", "");
}
/**
* 去掉字符串中所有符号,不论是全角,还是半角的,或是货币符号或者空格等
*
* @param s
* @return
*/
public static String removeSymbolForString(String s) {
StringBuffer buffer = new StringBuffer();
char[] chars = s.toCharArray();
for (int i = 0; i < chars.length; i++) {
md.update(msg.getBytes());
return new BigInteger(1, md.digest()).toString(16);
}
/**
* 处理字符串null值
*
* @param beforeStr 处理前字符串
* @return 处理后的字符串
*/
public static String dealNullStr(String beforeStr) {
if (null == beforeStr || beforeStr.length() == 0)
return "";
return beforeStr;
}
/**
* 使用参数Format将字符串转为Date
*
* @param strDate
* @param pattern
* @return
* @throws ParseException
*/
public static Date parse(String strDate, String pattern)
throws ParseException {
return new SimpleDateFormat(pattern).parse(strDate);
}
// /**
// * 过滤html文件中的图片文件
// * @param content
// * @return
// */
// public static String filterImg(String content)
// {
// return content.matches("/<img(?:.|\\s)*?>/g");
// }
public static void main(String[] args) {
String aa = "的付的反对法的发的说法";
char[] bb = aa.toCharArray();
for (char c : bb) {
System.out.println(c);
}
System.out.println(getBeforeMonth(1));
result = depotHeadMapper.updateByPrimaryKey(depotHead);
logService.insertLog("单据",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteDepotHead(Long id, HttpServletRequest request)throws Exception {
int result=0;
try{
result = depotHeadMapper.deleteByPrimaryKey(id);
logService.insertLog("单据",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(id).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotHead(String ids, HttpServletRequest request)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andIdIn(idList);
int result=0;
try{
result = depotHeadMapper.deleteByExample(example);
logService.insertLog("单据", "批量删除,id集:" + ids, request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
public int checkIsNameExist(Long id, String name)throws Exception {
DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<DepotHead> list = null;
try{
list = depotHeadMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list==null?0:list.size();
* 如果还不存在则调用Request .getRemoteAddr()。
*
* @param request
* @return
*/
public static String getIpAddr(HttpServletRequest request) {
String ip = request.getHeader("X-Real-IP");
if (!StringUtils.isEmpty(ip) && !"unknown".equalsIgnoreCase(ip)) {
return ip;
}
ip = request.getHeader("X-Forwarded-For");
if (!StringUtils.isEmpty(ip) && !"unknown".equalsIgnoreCase(ip)) {
// 多次反向代理后会有多个IP值,第一个为真实IP。
int index = ip.indexOf(',');
if (index != -1) {
return ip.substring(0, index);
} else {
return ip;
}
} else {
return request.getRemoteAddr();
}
}
/**
* 转化前台批量传入的ID值
*
* @param data
* @return 转化后的ID值数组
*/
public static int[] changeDataForm(String data) {
String[] dataStr = data.split(",");
int[] dataInt = new int[dataStr.length];
for (int i = 0; i < dataStr.length; i++)
dataInt[i] = Integer.parseInt(dataStr[i]);
return dataInt;
}
/**
* 解决导出文件中文乱码问题firefox和ie下中文乱码
*/
/**出库时处理序列号*/
if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())){
BigDecimal stock = getStockByParam(depotItem.getDepotid(),depotItem.getMaterialid(),null,null,tenantId);
BigDecimal thisBasicNumber = depotItem.getBasicnumber()==null?BigDecimal.ZERO:depotItem.getBasicnumber();
if(stock.compareTo(thisBasicNumber)<0){
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_CODE,
String.format(ExceptionConstants.MATERIAL_STOCK_NOT_ENOUGH_MSG,material==null?"":material.getName()));
}
if(!BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubtype())) {
/**
* 判断商品是否开启序列号,开启的收回序列号,未开启的跳过
* */
if(BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED.equals(material.getEnableserialnumber())) {
//查询单据子表中开启序列号的数据列表
serialNumberService.checkAndUpdateSerialNumber(depotItem, userInfo);
}
}
}
this.updateDepotItemWithObj(depotItem);
}
}
return null;
}
/**
* 查询计量单位信息
*
* @return
*/
public String findUnitName(Long mId) throws Exception{
String unitName = "";
try {
unitName = materialService.findUnitName(mId);
if (unitName != null) {
unitName = unitName.substring(1, unitName.length() - 1);
if (unitName.equals("null")) {
unitName = "";
}
}
} catch (Exception e) {
e.printStackTrace();
}
*/
public static String removeSymbolForString(String s) {
StringBuffer buffer = new StringBuffer();
char[] chars = s.toCharArray();
for (int i = 0; i < chars.length; i++) {
if ((chars[i] >= 19968 && chars[i] <= 40869) || (chars[i] >= 97 && chars[i] <= 122) || (chars[i] >= 65 && chars[i] <= 90)) {
buffer.append(chars[i]);
}
}
return buffer.toString();
}
/**
* 获取一个字符串的MD5
*
* @param msg
* @return 加密后的MD5字符串
* @throws NoSuchAlgorithmException
*/
public static String md5Encryp(String msg) throws NoSuchAlgorithmException {
// 生成一个MD5加密计算摘要
MessageDigest md = MessageDigest.getInstance("MD5");
// 计算md5函数
md.update(msg.getBytes());
return new BigInteger(1, md.digest()).toString(16);
}
/**
* 处理字符串null值
*
* @param beforeStr 处理前字符串
* @return 处理后的字符串
*/
public static String dealNullStr(String beforeStr) {
if (null == beforeStr || beforeStr.length() == 0)
return "";
return beforeStr;
}
/**
* 使用参数Format将字符串转为Date
*
* @param strDate
* @param pattern
* @return
* @throws ParseException
*/
public static Date parse(String strDate, String pattern)
int result=0;
try{
result=userMapper.updateByPrimaryKeySelective(user);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
/**
* create by: cjl
* description:
* 添加事务控制
* @Param: md5Pwd
* @Param: id
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int resetPwd(String md5Pwd, Long id) throws Exception{
logService.insertLog("用户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User user = new User();
user.setId(id);
user.setPassword(md5Pwd);
int result=0;
try{
result=userMapper.updateByPrimaryKeySelective(user);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteUser(Long id, HttpServletRequest request)throws Exception {
int result=0;
try{
result= userMapper.deleteByPrimaryKey(id);
logService.insertLog("用户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(id).toString(), request);
}catch(Exception e){
String ratioList = unitName.substring(unitName.indexOf("("));
String basicUnit = unitList.substring(0, unitList.indexOf(",")); //基本单位
String otherUnit = unitList.substring(unitList.indexOf(",") + 1); //副单位
Integer ratio = Integer.parseInt(ratioList.substring(ratioList.indexOf(":") + 1).replace(")", "")); //比例
if (Unit.equals(basicUnit)) { //如果等于基础单位
depotItem.setBasicnumber(oNumber); //数量一致
} else if (Unit.equals(otherUnit)) { //如果等于副单位
depotItem.setBasicnumber(oNumber.multiply(new BigDecimal(ratio))); //数量乘以比例
}
} else {
depotItem.setBasicnumber(oNumber); //其他情况
}
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e);
}
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("UnitPrice").toString())) {
depotItem.setUnitprice(tempUpdatedJson.getBigDecimal("UnitPrice"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxUnitPrice").toString())) {
depotItem.setTaxunitprice(tempUpdatedJson.getBigDecimal("TaxUnitPrice"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("AllPrice").toString())) {
depotItem.setAllprice(tempUpdatedJson.getBigDecimal("AllPrice"));
}
depotItem.setRemark(tempUpdatedJson.getString("Remark"));
if (tempUpdatedJson.get("DepotId") != null && !StringUtil.isEmpty(tempUpdatedJson.get("DepotId").toString())) {
depotItem.setDepotid(tempUpdatedJson.getLong("DepotId"));
}
if (tempUpdatedJson.get("AnotherDepotId") != null && !StringUtil.isEmpty(tempUpdatedJson.get("AnotherDepotId").toString())) {
depotItem.setAnotherdepotid(tempUpdatedJson.getLong("AnotherDepotId"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxRate").toString())) {
depotItem.setTaxrate(tempUpdatedJson.getBigDecimal("TaxRate"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxMoney").toString())) {
depotItem.setTaxmoney(tempUpdatedJson.getBigDecimal("TaxMoney"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxLastMoney").toString())) {
depotItem.setTaxlastmoney(tempUpdatedJson.getBigDecimal("TaxLastMoney"));
}
depotItem.setOtherfield1(tempUpdatedJson.getString("OtherField1"));
depotItem.setOtherfield2(tempUpdatedJson.getString("OtherField2"));
* @Param: serialNumberPrefix
* @Param: batAddTotal
* @Param: remark
* @return java.lang.Object
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void batAddSerialNumber(String materialName, String serialNumberPrefix, Integer batAddTotal, String remark)throws Exception {
logService.insertLog("序列号",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_BATCH_ADD).append(batAddTotal).append(BusinessConstants.LOG_DATA_UNIT).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
if(StringUtil.isNotEmpty(materialName)){
//查询商品id
Long materialId = checkMaterialName(materialName);
List<SerialNumberEx> list=null;
//当前用户
User userInfo=userService.getCurrentUser();
Long userId=userInfo==null?null:userInfo.getId();
Date date = null;
Long million=null;
synchronized(this){
date = new Date();
million=date.getTime();
}
int insertNum=0;
StringBuffer prefixBuf=new StringBuffer(serialNumberPrefix).append(million);
list=new ArrayList<SerialNumberEx>();
int forNum = BusinessConstants.BATCH_INSERT_MAX_NUMBER>=batAddTotal?batAddTotal:BusinessConstants.BATCH_INSERT_MAX_NUMBER;
for(int i=0;i<forNum;i++){
insertNum++;
SerialNumberEx each=new SerialNumberEx();
each.setMaterialId(materialId);
each.setCreator(userId);
each.setCreateTime(date);
each.setUpdater(userId);
each.setUpdateTime(date);
each.setRemark(remark);
each.setSerialNumber(new StringBuffer(prefixBuf.toString()).append(insertNum).toString());
list.add(each);
}
try{
serialNumberMapperEx.batAddSerialNumber(list);
}catch(Exception e){
JshException.writeFail(logger, e);
}
}
}
/**
* create by: qiankunpingtai
* website:https://qiankunpingtai.cn
* description:
* 逻辑删除序列号信息
materialOther = materialOther + ((diEx.getMColor() == null || diEx.getMColor().equals("")) ? "" : "(" + diEx.getMColor() + ")");
}
if (mpArr[i].equals("规格")) {
materialOther = materialOther + ((diEx.getMStandard() == null || diEx.getMStandard().equals("")) ? "" : "(" + diEx.getMStandard() + ")");
}
if (mpArr[i].equals("制造商")) {
materialOther = materialOther + ((diEx.getMMfrs() == null || diEx.getMMfrs().equals("")) ? "" : "(" + diEx.getMMfrs() + ")");
}
if (mpArr[i].equals("自定义1")) {
materialOther = materialOther + ((diEx.getMOtherField1() == null || diEx.getMOtherField1().equals("")) ? "" : "(" + diEx.getMOtherField1() + ")");
}
if (mpArr[i].equals("自定义2")) {
materialOther = materialOther + ((diEx.getMOtherField2() == null || diEx.getMOtherField2().equals("")) ? "" : "(" + diEx.getMOtherField2() + ")");
}
if (mpArr[i].equals("自定义3")) {
materialOther = materialOther + ((diEx.getMOtherField3() == null || diEx.getMOtherField3().equals("")) ? "" : "(" + diEx.getMOtherField3() + ")");
}
}
return materialOther;
}
/**
* 查找所有的明细
* @param currentPage
* @param pageSize
* @param projectId
* @param monthTime
* @param headIds
* @param materialIds
* @param mpList
* @param request
* @return
*/
@PostMapping(value = "/findByAll")
public BaseResponseInfo findByAll(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize,
@RequestParam("depotId") Long depotId,
@RequestParam("monthTime") String monthTime,
@RequestParam("headIds") String headIds,
@RequestParam("materialIds") String materialIds,
@RequestParam("mpList") String mpList,
HttpServletRequest request)throws Exception {
result=depotItemMapper.deleteByExample(example);
logService.insertLog("单据明细", "批量删除,id集:" + ids, request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
public int checkIsNameExist(Long id, String name)throws Exception {
DepotItemExample example = new DepotItemExample();
example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<DepotItem> list =null;
try{
list=depotItemMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list==null?0:list.size();
}
public List<DepotItemVo4DetailByTypeAndMId> findDetailByTypeAndMaterialIdList(Map<String, String> map)throws Exception {
String mIdStr = map.get("mId");
Long mId = null;
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
}
List<DepotItemVo4DetailByTypeAndMId> list =null;
try{
list = depotItemMapperEx.findDetailByTypeAndMaterialIdList(mId, QueryUtils.offset(map), QueryUtils.rows(map));
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public Long findDetailByTypeAndMaterialIdCounts(Map<String, String> map)throws Exception {
String mIdStr = map.get("mId");
Long mId = null;
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
}
Long result =null;
try{
result = depotItemMapperEx.findDetailByTypeAndMaterialIdCounts(mId);
JshException.writeFail(logger, e);
}
if(result>0){
return ue;
}
return null;
}
/**
* create by: cjl
* description:
* 检查用户名称和登录名不能重复
* @Param: userEx
* @return void
*/
public void checkUserNameAndLoginName(UserEx userEx)throws Exception{
List<User> list=null;
if(userEx==null){
return;
}
Long userId=userEx.getId();
//检查登录名
if(!StringUtils.isEmpty(userEx.getLoginame())){
String loginName=userEx.getLoginame();
list=this.getUserListByloginName(loginName);
if(list!=null&&list.size()>0){
if(list.size()>1){
//超过一条数据存在,该登录名已存在
logger.error("异常码[{}],异常提示[{}],参数,loginName:[{}]",
ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG,loginName);
throw new BusinessRunTimeException(ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,
ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG);
}
//一条数据,新增时抛出异常,修改时和当前的id不同时抛出异常
if(list.size()==1){
if(userId==null||(userId!=null&&!userId.equals(list.get(0).getId()))){
logger.error("异常码[{}],异常提示[{}],参数,loginName:[{}]",
ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG,loginName);
throw new BusinessRunTimeException(ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,
ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG);
}
}
}
}
//检查用户名
if(!StringUtils.isEmpty(userEx.getUsername())){
public int findInOutMaterialCountTotal(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId)throws Exception {
int result = 0;
try{
result =depotHeadMapperEx.findInOutMaterialCountTotal(beginTime, endTime, type, pid, dids, oId);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public List<DepotHeadVo4StatementAccount> findStatementAccount(String beginTime, String endTime, Integer organId, String supType, Integer offset, Integer rows)throws Exception {
List<DepotHeadVo4StatementAccount> list = null;
try{
list =depotHeadMapperEx.findStatementAccount(beginTime, endTime, organId, supType, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public int findStatementAccountCount(String beginTime, String endTime, Integer organId, String supType) throws Exception{
int result = 0;
try{
result =depotHeadMapperEx.findStatementAccountCount(beginTime, endTime, organId, supType);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public BigDecimal findAllMoney(Integer supplierId, String type, String subType, String mode, String endTime)throws Exception {
String modeName = "";
if (mode.equals("实际")) {
modeName = "ChangeAmount";
} else if (mode.equals("合计")) {
modeName = "DiscountLastMoney";
}
BigDecimal result = null;
try{
result =depotHeadMapperEx.findAllMoney(supplierId, type, subType, modeName, endTime);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
/**
* 统计总金额
* @param getS
* @param type
* @param subType
* @param mode 合计或者金额
* @return
JSONObject tempUpdatedJson = JSONObject.parseObject(updatedJson.getString(i));
AccountItem accountItem = this.getAccountItem(tempUpdatedJson.getLong("Id"));
accountItem.setId(tempUpdatedJson.getLong("Id"));
accountItem.setHeaderid(headerId);
if (tempUpdatedJson.get("AccountId") != null && !tempUpdatedJson.get("AccountId").equals("")) {
accountItem.setAccountid(tempUpdatedJson.getLong("AccountId"));
}
if (tempUpdatedJson.get("InOutItemId") != null && !tempUpdatedJson.get("InOutItemId").equals("")) {
accountItem.setInoutitemid(tempUpdatedJson.getLong("InOutItemId"));
}
if (tempUpdatedJson.get("EachAmount") != null && !tempUpdatedJson.get("EachAmount").equals("")) {
BigDecimal eachAmount = tempUpdatedJson.getBigDecimal("EachAmount");
if (listType.equals("付款")) {
eachAmount = BigDecimal.ZERO.subtract(eachAmount);
}
accountItem.setEachamount(eachAmount);
} else {
accountItem.setEachamount(BigDecimal.ZERO);
}
accountItem.setRemark(tempUpdatedJson.getString("Remark"));
this.updateAccountItemWithObj(accountItem);
}
}
return null;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccountItemByIds(String ids) throws Exception{
logService.insertLog("财务明细",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
int result=0;
try{
result = accountItemMapperEx.batchDeleteAccountItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
}
return res;
}
/**
* 查询计量单位信息
*
* @return
*/
public String findUnitName(Long mId)throws Exception {
String unitName = "";
try {
unitName = materialService.findUnitName(mId);
if (unitName != null) {
unitName = unitName.substring(1, unitName.length() - 1);
if (unitName.equals("null")) {
unitName = "";
}
}
} catch (Exception e) {
e.printStackTrace();
}
return unitName;
}
@GetMapping(value = "/getDetailList")
public BaseResponseInfo getDetailList(@RequestParam("headerId") Long headerId,
@RequestParam("mpList") String mpList,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
try {
List<DepotItemVo4WithInfoEx> dataList = new ArrayList<DepotItemVo4WithInfoEx>();
if(headerId != 0) {
dataList = depotItemService.getDetailList(headerId);
}
String[] mpArr = mpList.split(",");
JSONObject outer = new JSONObject();
outer.put("total", dataList.size());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (DepotItemVo4WithInfoEx diEx : dataList) {
JSONObject item = new JSONObject();
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e);
}
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("UnitPrice").toString())) {
depotItem.setUnitprice(tempUpdatedJson.getBigDecimal("UnitPrice"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxUnitPrice").toString())) {
depotItem.setTaxunitprice(tempUpdatedJson.getBigDecimal("TaxUnitPrice"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("AllPrice").toString())) {
depotItem.setAllprice(tempUpdatedJson.getBigDecimal("AllPrice"));
}
depotItem.setRemark(tempUpdatedJson.getString("Remark"));
if (tempUpdatedJson.get("DepotId") != null && !StringUtil.isEmpty(tempUpdatedJson.get("DepotId").toString())) {
depotItem.setDepotid(tempUpdatedJson.getLong("DepotId"));
}
if (tempUpdatedJson.get("AnotherDepotId") != null && !StringUtil.isEmpty(tempUpdatedJson.get("AnotherDepotId").toString())) {
depotItem.setAnotherdepotid(tempUpdatedJson.getLong("AnotherDepotId"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxRate").toString())) {
depotItem.setTaxrate(tempUpdatedJson.getBigDecimal("TaxRate"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxMoney").toString())) {
depotItem.setTaxmoney(tempUpdatedJson.getBigDecimal("TaxMoney"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxLastMoney").toString())) {
depotItem.setTaxlastmoney(tempUpdatedJson.getBigDecimal("TaxLastMoney"));
}
depotItem.setOtherfield1(tempUpdatedJson.getString("OtherField1"));
depotItem.setOtherfield2(tempUpdatedJson.getString("OtherField2"));
depotItem.setOtherfield3(tempUpdatedJson.getString("OtherField3"));
depotItem.setOtherfield4(tempUpdatedJson.getString("OtherField4"));
depotItem.setOtherfield5(tempUpdatedJson.getString("OtherField5"));
depotItem.setMtype(tempUpdatedJson.getString("MType"));
/**
* create by: qiankunpingtai
* website:https://qiankunpingtai.cn
* description:
* 修改了商品类型时,库中的商品和页面传递的不同
* 这里需要重新获取页面传递的商品信息
*/
if(!material.getId().equals(depotItem.getMaterialid())){
material= materialService.getMaterial(depotItem.getMaterialid());
if(material==null){
continue;
}
}
/**出库时处理序列号*/
if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())){
BigDecimal stock = getStockByParam(depotItem.getDepotid(),depotItem.getMaterialid(),null,null,tenantId);
BigDecimal thisBasicNumber = depotItem.getBasicnumber()==null?BigDecimal.ZERO:depotItem.getBasicnumber();