| New file |
| | |
| | | package com.example.erp.service.mm; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.example.erp.entity.mm.*; |
| | | import com.example.erp.entity.sd.*; |
| | | import com.example.erp.entity.userInfo.Log; |
| | | import com.example.erp.entity.userInfo.SysError; |
| | | import com.example.erp.mapper.mm.BasicWarehouseTypeMapper; |
| | | import com.example.erp.mapper.mm.FinishedGlassShelfMapper; |
| | | import com.example.erp.mapper.mm.MaterialInventoryMapper; |
| | | import com.example.erp.mapper.mm.MaterialStoreMapper; |
| | | import com.example.erp.service.userInfo.LogService; |
| | | import com.example.erp.service.userInfo.SysErrorService; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | @DS("mm") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public class FinishedGlassShelfService { |
| | | @Autowired |
| | | FinishedGlassShelfMapper finishedGlassShelfMapper; |
| | | @Autowired |
| | | SysErrorService sysErrorService; |
| | | @Autowired |
| | | LogService logService; |
| | | |
| | | public String saveFinishedGlassShelf(Map<String,Object> object) { |
| | | String saveState = "true"; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | try { |
| | | Log log = new Log(); |
| | | log.setOperatorId(object.get("userId").toString()); |
| | | log.setOperator(object.get("userName").toString()); |
| | | log.setContent(object.toString()); |
| | | |
| | | String userName = ""; |
| | | if (object.get("userName") != null) { |
| | | userName = object.get("userName").toString(); |
| | | } |
| | | |
| | | String inventoryArea = ""; |
| | | if (object.get("inventoryArea") != null) { |
| | | inventoryArea = object.get("inventoryArea").toString(); |
| | | } |
| | | |
| | | int quantity = 0; |
| | | if (object.get("quantity") != null) { |
| | | quantity = Integer.valueOf(object.get("quantity").toString()); |
| | | } |
| | | |
| | | FinishedGlassShelfInformation finishedGlassShelfInformation = |
| | | JSONObject.parseObject(JSONObject.toJSONString(object.get("title")), FinishedGlassShelfInformation.class); |
| | | |
| | | List<FinishedGlassShelfInformation> finishedGlassShelfInformationList=finishedGlassShelfMapper |
| | | .getSelectFinishedGlassShelfInformation(finishedGlassShelfInformation); |
| | | |
| | | if(finishedGlassShelfInformation.getId()>0){ |
| | | finishedGlassShelfMapper.updateFinishedGlassShelfInformation(finishedGlassShelfInformation,finishedGlassShelfInformation.getId()); |
| | | log.setFunction("saveFinishedGlassShelf修改1"); |
| | | }else{ |
| | | int index=finishedGlassShelfMapper.getSelectFinishedGlassShelfInformationInventoryArea(inventoryArea); |
| | | for (int i=1;i<=quantity;i++){ |
| | | index++; |
| | | finishedGlassShelfMapper.insetFinishedGlassShelfInformation(finishedGlassShelfInformation,inventoryArea+index); |
| | | } |
| | | log.setFunction("saveFinishedGlassShelf新增"); |
| | | |
| | | finishedGlassShelfMapper.insetFinishedGlassShelfLog(finishedGlassShelfInformation,quantity); |
| | | |
| | | } |
| | | |
| | | logService.saveLog(log); |
| | | |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e+Arrays.toString(e.getStackTrace())); |
| | | sysError.setFunc("saveFinishedGlassShelf"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = "false"; |
| | | |
| | | } |
| | | return saveState; |
| | | |
| | | } |
| | | |
| | | public Map<String, Object> getSelectFinishedGlassShelfInformation(Integer pageNum, Integer pageSize,String type) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if(type.equals("1")){ |
| | | map.put("data", finishedGlassShelfMapper.getSelectFinishedGlassShelfInformationDate(offset, pageSize)); |
| | | map.put("total", finishedGlassShelfMapper.getSelectFinishedGlassShelfInformationDatePageTotal(offset, pageSize)); |
| | | }else{ |
| | | map.put("data", finishedGlassShelfMapper.getSelectFinishedGlassShelfInformationDateDetail(offset, pageSize)); |
| | | map.put("total", finishedGlassShelfMapper.getSelectFinishedGlassShelfInformationDateDetailPageTotal(offset, pageSize)); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> getSelectFinishedGlassShelfInformationById(Long id) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", finishedGlassShelfMapper.getSelectFinishedGlassShelfInformationById(id)); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | public String deleteFinishedGlassShelfInformationById(Map<String,Object> object) { |
| | | String saveState = "true"; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | try { |
| | | Long id = 0l; |
| | | if (object.get("id") != null) { |
| | | id = Long.valueOf(object.get("id").toString()); |
| | | } |
| | | |
| | | finishedGlassShelfMapper.deleteFinishedGlassShelfInformationById(id); |
| | | |
| | | Log log = new Log(); |
| | | log.setOperatorId(object.get("userId").toString()); |
| | | log.setOperator(object.get("userName").toString()); |
| | | log.setContent(object.toString()); |
| | | log.setFunction("deleteFinishedGlassShelfInformationById删除:"+id); |
| | | logService.saveLog(log); |
| | | |
| | | |
| | | |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e+Arrays.toString(e.getStackTrace())); |
| | | sysError.setFunc("eleteFinishedGlassShelfInformationById"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = "false"; |
| | | |
| | | } |
| | | return saveState; |
| | | |
| | | } |
| | | |
| | | public Map<String, Object> getSelectFinishedGlassShelfInformationDetails(Integer pageNum, Integer pageSize, List<Map<String, Object>> object) { |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<Map<String, Object>> mapList=new ArrayList<>(); |
| | | for(Map<String, Object> objectMap:object){ |
| | | mapList.add(finishedGlassShelfMapper.getSelectFinishedGlassShelfInformationInId( |
| | | objectMap.get("glassShelfName").toString(), |
| | | Double.parseDouble(objectMap.get("price").toString()), |
| | | objectMap.get("unit").toString(), |
| | | Double.parseDouble(objectMap.get("weight").toString()), |
| | | Double.parseDouble(objectMap.get("width").toString()), |
| | | Double.parseDouble(objectMap.get("height").toString()) |
| | | )); |
| | | |
| | | } |
| | | map.put("data", mapList); |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> getSelectFinishedGlassShelfEmitDetails(Integer pageNum, Integer pageSize, String emitId) { |
| | | if (emitId.startsWith("\"") && emitId.endsWith("\"")) { |
| | | emitId = emitId.substring(1, emitId.length() - 1); // 去除首尾引号 |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("emit", finishedGlassShelfMapper.getSelectFinishedGlassShelfEmitByemitId(emitId)); |
| | | map.put("data", finishedGlassShelfMapper.getSelectFinishedGlassShelfEmitDetailsByemitId(emitId)); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | public String insertFinishedGlassShelfEmit(Map<String,Object> object) { |
| | | |
| | | String saveState = "true"; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | |
| | | try { |
| | | String emitId=""; |
| | | String oddNumber = null; |
| | | if (object.get("emitId") != null) { |
| | | emitId = object.get("emitId").toString(); |
| | | } else { |
| | | emitId = ""; |
| | | } |
| | | FinishedGlassShelfEmit finishedGlassShelfEmit = JSONObject.parseObject(JSONObject.toJSONString(object.get("title")), FinishedGlassShelfEmit.class); |
| | | List<FinishedGlassShelfEmitDetails> finishedGlassShelfEmitDetailsList = JSONArray.parseArray(JSONObject.toJSONString(object.get("emitDetails")), FinishedGlassShelfEmitDetails.class); |
| | | //查询出库单是否存在 |
| | | FinishedGlassShelfEmit finishedGlassShelfEmit2 = finishedGlassShelfMapper.getSelectFinishedGlassShelfEmitByemitId(emitId); |
| | | |
| | | Log log = new Log(); |
| | | log.setOperator(object.get("userName").toString()); |
| | | log.setOperatorId(object.get("userId").toString()); |
| | | log.setContent(object.toString()); |
| | | |
| | | if (finishedGlassShelfEmit2 != null) { |
| | | //编辑还原数据 |
| | | List<FinishedGlassShelfEmitDetails> finishedGlassShelfEmitDetailsList2 = finishedGlassShelfMapper.getSelectFinishedGlassShelfEmitDetailsByemitId1(emitId); |
| | | if (!finishedGlassShelfEmitDetailsList2.isEmpty()) { |
| | | for (FinishedGlassShelfEmitDetails finishedGlassShelfEmitDetails : finishedGlassShelfEmitDetailsList2) { |
| | | finishedGlassShelfMapper.updateInformationAvailableQuantityInt( |
| | | finishedGlassShelfEmitDetails.getMaxWeight(), |
| | | finishedGlassShelfEmitDetails.getMaxWidth(), |
| | | finishedGlassShelfEmitDetails.getMaxHeight(), |
| | | finishedGlassShelfEmitDetails.getQuantity(), |
| | | finishedGlassShelfEmitDetails.getPrice(), |
| | | finishedGlassShelfEmitDetails.getUnit(), |
| | | finishedGlassShelfEmitDetails.getGlassShelfName()); |
| | | finishedGlassShelfMapper.deleteFinishedGlassShelfEmitDetails(emitId); |
| | | finishedGlassShelfMapper.deleteFinishedGlassShelfEmitDetailsLog(emitId); |
| | | } |
| | | } |
| | | |
| | | oddNumber = emitId; |
| | | finishedGlassShelfMapper.updateFinishedGlassShelfEmit(finishedGlassShelfEmit, oddNumber); |
| | | log.setFunction("insertEmit修改:"+oddNumber); |
| | | } else { |
| | | //获取单号 |
| | | oddNumber = orderNumberSetting("出库"); |
| | | //新增出库数据 |
| | | finishedGlassShelfMapper.insertFinishedGlassShelfEmit(finishedGlassShelfEmit, oddNumber); |
| | | log.setFunction("insertFinishedGlassShelfEmit新增:"+oddNumber); |
| | | } |
| | | |
| | | //获取对象集合循环进行新增修改 |
| | | if (finishedGlassShelfEmitDetailsList.size()>0) { |
| | | int index=1; |
| | | for (FinishedGlassShelfEmitDetails finishedGlassShelfEmitDetails:finishedGlassShelfEmitDetailsList){ |
| | | finishedGlassShelfEmitDetails.setMoney(finishedGlassShelfEmitDetails.getPrice()*finishedGlassShelfEmitDetails.getQuantity()); |
| | | finishedGlassShelfMapper.updateInformationAvailableQuantityOut( |
| | | finishedGlassShelfEmitDetails.getMaxWeight(), |
| | | finishedGlassShelfEmitDetails.getMaxWidth(), |
| | | finishedGlassShelfEmitDetails.getMaxHeight(), |
| | | finishedGlassShelfEmitDetails.getQuantity(), |
| | | finishedGlassShelfEmitDetails.getPrice(), |
| | | finishedGlassShelfEmitDetails.getUnit(), |
| | | finishedGlassShelfEmitDetails.getGlassShelfName()); |
| | | finishedGlassShelfMapper.insertFinishedGlassShelfEmitDetails(oddNumber,index,finishedGlassShelfEmitDetails); |
| | | finishedGlassShelfMapper.insertFinishedGlassShelfEmitDetailsLog( |
| | | oddNumber, |
| | | index, |
| | | 1, |
| | | finishedGlassShelfEmitDetails.getQuantity(), |
| | | finishedGlassShelfEmitDetails.getPrice(), |
| | | finishedGlassShelfEmitDetails.getMoney(), |
| | | finishedGlassShelfEmitDetails.getUnit(), |
| | | finishedGlassShelfEmitDetails.getRemarks(), |
| | | finishedGlassShelfEmitDetails.getMaxWeight(), |
| | | finishedGlassShelfEmitDetails.getMaxWidth(), |
| | | finishedGlassShelfEmitDetails.getMaxHeight(), |
| | | finishedGlassShelfEmitDetails.getGlassShelfName(), |
| | | object.get("userName").toString() |
| | | ); |
| | | index++; |
| | | } |
| | | logService.saveLog(log); |
| | | } else { |
| | | return "false3"; |
| | | } |
| | | }catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e+Arrays.toString(e.getStackTrace())); |
| | | sysError.setFunc("insertFinishedGlassShelfEmit"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = "false4"; |
| | | |
| | | } |
| | | |
| | | return saveState; |
| | | } |
| | | |
| | | |
| | | public Map<String, Object> getSelectFinishedGlassShelfEmit(Integer pageNum, Integer pageSize,List<String> selectDate, |
| | | FinishedGlassShelfEmit finishedGlassShelfEmit) throws JsonProcessingException { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(15).toString(); |
| | | if(selectDate !=null && selectDate.size()==2){ |
| | | if(!selectDate.get(0).isEmpty()){ |
| | | startDate = selectDate.get(0); |
| | | } |
| | | if(!selectDate.get(1).isEmpty()){ |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", finishedGlassShelfMapper.getSelectFinishedGlassShelfEmit(offset, pageSize,startDate,endDate, finishedGlassShelfEmit)); |
| | | map.put("total", finishedGlassShelfMapper.getSelectFinishedGlassShelfEmitPageTotal(offset, pageSize,startDate,endDate, finishedGlassShelfEmit)); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | public String deleteFinishedGlassShelfEmit(Map<String,Object> object) { |
| | | String saveState = "true"; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | try { |
| | | String emitId = ""; |
| | | if (object.get("emitId") != null) { |
| | | emitId = object.get("emitId").toString(); |
| | | } |
| | | FinishedGlassShelfEmit finishedGlassShelfEmit2 = finishedGlassShelfMapper.getSelectFinishedGlassShelfEmitByemitId(emitId); |
| | | |
| | | if (finishedGlassShelfEmit2 != null) { |
| | | |
| | | if(finishedGlassShelfEmit2.getState()==0){ |
| | | //编辑还原数据 |
| | | List<FinishedGlassShelfEmitDetails> finishedGlassShelfEmitDetailsList2 = finishedGlassShelfMapper.getSelectFinishedGlassShelfEmitDetailsByemitId1(emitId); |
| | | if (!finishedGlassShelfEmitDetailsList2.isEmpty()) { |
| | | for (FinishedGlassShelfEmitDetails finishedGlassShelfEmitDetails : finishedGlassShelfEmitDetailsList2) { |
| | | finishedGlassShelfMapper.updateInformationAvailableQuantityInt( |
| | | finishedGlassShelfEmitDetails.getMaxWeight(), |
| | | finishedGlassShelfEmitDetails.getMaxWidth(), |
| | | finishedGlassShelfEmitDetails.getMaxHeight(), |
| | | finishedGlassShelfEmitDetails.getQuantity(), |
| | | finishedGlassShelfEmitDetails.getPrice(), |
| | | finishedGlassShelfEmitDetails.getUnit(), |
| | | finishedGlassShelfEmitDetails.getGlassShelfName()); |
| | | finishedGlassShelfMapper.deleteFinishedGlassShelfEmitDetailsLog(emitId); |
| | | } |
| | | finishedGlassShelfMapper.deleteFinishedGlassShelfEmitDetails(emitId); |
| | | finishedGlassShelfMapper.deleteFinishedGlassShelfEmit(emitId); |
| | | } |
| | | }else{ |
| | | saveState = "false1"; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | Log log = new Log(); |
| | | log.setOperatorId(object.get("userId").toString()); |
| | | log.setOperator(object.get("userName").toString()); |
| | | log.setContent(object.toString()); |
| | | log.setFunction("deleteFinishedGlassShelfEmit删除:"+emitId); |
| | | logService.saveLog(log); |
| | | |
| | | }catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e+Arrays.toString(e.getStackTrace())); |
| | | sysError.setFunc("deleteFinishedGlassShelfEmit"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = "false"; |
| | | |
| | | } |
| | | return saveState; |
| | | |
| | | } |
| | | |
| | | |
| | | public String insertFinishedGlassShelfWithdraw(Map<String,Object> object) { |
| | | |
| | | String saveState = "true"; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | |
| | | try { |
| | | String withdrawId=""; |
| | | String oddNumber = null; |
| | | if (object.get("withdrawId") != null) { |
| | | withdrawId = object.get("withdrawId").toString(); |
| | | } else { |
| | | withdrawId = ""; |
| | | } |
| | | FinishedGlassShelfWithdraw finishedGlassShelfWithdraw = JSONObject.parseObject(JSONObject.toJSONString(object.get("title")), FinishedGlassShelfWithdraw.class); |
| | | List<FinishedGlassShelfWithdrawDetails> finishedGlassShelfWithdrawDetailsList = JSONArray.parseArray(JSONObject.toJSONString(object.get("withdrawDetails")), FinishedGlassShelfWithdrawDetails.class); |
| | | //查询入库单是否存在 |
| | | FinishedGlassShelfWithdraw finishedGlassShelfWithdraw2 = finishedGlassShelfMapper.getSelectFinishedGlassShelfWithdrawByemitId(withdrawId); |
| | | |
| | | Log log = new Log(); |
| | | log.setOperator(object.get("userName").toString()); |
| | | log.setOperatorId(object.get("userId").toString()); |
| | | log.setContent(object.toString()); |
| | | |
| | | if (finishedGlassShelfWithdraw2 != null) { |
| | | //编辑还原数据 |
| | | List<FinishedGlassShelfWithdrawDetails> finishedGlassShelfWithdrawDetailsList2 = finishedGlassShelfMapper |
| | | .getSelectFinishedGlassShelfWithdrawDetailsBywithdrawId1(withdrawId); |
| | | if (!finishedGlassShelfWithdrawDetailsList2.isEmpty()) { |
| | | for (FinishedGlassShelfWithdrawDetails finishedGlassShelfWithdrawDetails : finishedGlassShelfWithdrawDetailsList2) { |
| | | finishedGlassShelfMapper.updateEmitDetailsWithdrawQuantityOut(finishedGlassShelfWithdrawDetails); |
| | | finishedGlassShelfMapper.updateInformationAvailableQuantityOut( |
| | | finishedGlassShelfWithdrawDetails.getMaxWeight(), |
| | | finishedGlassShelfWithdrawDetails.getMaxWidth(), |
| | | finishedGlassShelfWithdrawDetails.getMaxHeight(), |
| | | finishedGlassShelfWithdrawDetails.getQuantity(), |
| | | finishedGlassShelfWithdrawDetails.getPrice(), |
| | | finishedGlassShelfWithdrawDetails.getUnit(), |
| | | finishedGlassShelfWithdrawDetails.getGlassShelfName() |
| | | ); |
| | | finishedGlassShelfMapper.deleteFinishedGlassShelfWithdrawDetails(withdrawId); |
| | | finishedGlassShelfMapper.deleteFinishedGlassShelfEmitDetailsLog(withdrawId); |
| | | } |
| | | } |
| | | |
| | | oddNumber = withdrawId; |
| | | finishedGlassShelfMapper.updateFinishedGlassShelfWithdraw(finishedGlassShelfWithdraw, oddNumber); |
| | | log.setFunction("insertWithdraw修改:"+oddNumber); |
| | | } else { |
| | | //获取单号 |
| | | oddNumber = orderNumberSetting("入库"); |
| | | //新增出库数据 |
| | | finishedGlassShelfMapper.insertFinishedGlassShelfWithdraw(finishedGlassShelfWithdraw, oddNumber); |
| | | log.setFunction("insertFinishedGlassShelfWithdraw新增:"+oddNumber); |
| | | } |
| | | |
| | | //获取对象集合循环进行新增修改 |
| | | if (finishedGlassShelfWithdrawDetailsList.size()>0) { |
| | | int index=1; |
| | | for (FinishedGlassShelfWithdrawDetails finishedGlassShelfWithdrawDetails:finishedGlassShelfWithdrawDetailsList){ |
| | | if(finishedGlassShelfWithdrawDetails.getQuantity()>0){ |
| | | finishedGlassShelfWithdrawDetails.setMoney(finishedGlassShelfWithdrawDetails.getPrice()*finishedGlassShelfWithdrawDetails.getQuantity()); |
| | | finishedGlassShelfMapper.updateEmitDetailsWithdrawQuantityInt(finishedGlassShelfWithdrawDetails); |
| | | finishedGlassShelfMapper.updateInformationAvailableQuantityInt( |
| | | finishedGlassShelfWithdrawDetails.getMaxWeight(), |
| | | finishedGlassShelfWithdrawDetails.getMaxWidth(), |
| | | finishedGlassShelfWithdrawDetails.getMaxHeight(), |
| | | finishedGlassShelfWithdrawDetails.getQuantity(), |
| | | finishedGlassShelfWithdrawDetails.getPrice(), |
| | | finishedGlassShelfWithdrawDetails.getUnit(), |
| | | finishedGlassShelfWithdrawDetails.getGlassShelfName() |
| | | ); |
| | | finishedGlassShelfMapper.insertFinishedGlassShelfWithdrawDetails(oddNumber,index,finishedGlassShelfWithdrawDetails); |
| | | finishedGlassShelfMapper.insertFinishedGlassShelfEmitDetailsLog( |
| | | oddNumber, |
| | | index, |
| | | 2, |
| | | finishedGlassShelfWithdrawDetails.getQuantity(), |
| | | finishedGlassShelfWithdrawDetails.getPrice(), |
| | | finishedGlassShelfWithdrawDetails.getMoney(), |
| | | finishedGlassShelfWithdrawDetails.getUnit(), |
| | | finishedGlassShelfWithdrawDetails.getRemarks(), |
| | | finishedGlassShelfWithdrawDetails.getMaxWeight(), |
| | | finishedGlassShelfWithdrawDetails.getMaxWidth(), |
| | | finishedGlassShelfWithdrawDetails.getMaxHeight(), |
| | | finishedGlassShelfWithdrawDetails.getGlassShelfName(), |
| | | object.get("userName").toString() |
| | | ); |
| | | index++; |
| | | } |
| | | |
| | | } |
| | | getUpdateFinishedGlassShelfEmitState(finishedGlassShelfWithdrawDetailsList.get(0).getEmitId()); |
| | | logService.saveLog(log); |
| | | } else { |
| | | return "false3"; |
| | | } |
| | | }catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e+Arrays.toString(e.getStackTrace())); |
| | | sysError.setFunc("insertFinishedGlassShelfWithdraw"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = "false4"; |
| | | |
| | | } |
| | | |
| | | return saveState; |
| | | } |
| | | |
| | | public void getUpdateFinishedGlassShelfEmitState(String emitId) { |
| | | List<FinishedGlassShelfEmitDetails> finishedGlassShelfEmitDetailsList2 = finishedGlassShelfMapper |
| | | .getSelectFinishedGlassShelfEmitDetailsByemitId1(emitId); |
| | | int sumWithdrawQuantity=0; |
| | | finishedGlassShelfMapper.updateFinishedGlassShelfEmitState(2,emitId); |
| | | for(FinishedGlassShelfEmitDetails finishedGlassShelfEmitDetails:finishedGlassShelfEmitDetailsList2){ |
| | | sumWithdrawQuantity+=finishedGlassShelfEmitDetails.getWithdrawQuantity(); |
| | | if(finishedGlassShelfEmitDetails.getQuantity()!=finishedGlassShelfEmitDetails.getWithdrawQuantity()){ |
| | | finishedGlassShelfMapper.updateFinishedGlassShelfEmitState(1,emitId); |
| | | } |
| | | } |
| | | if(sumWithdrawQuantity==0){ |
| | | finishedGlassShelfMapper.updateFinishedGlassShelfEmitState(0,emitId); |
| | | } |
| | | } |
| | | |
| | | |
| | | public Map<String, Object> getSelectFinishedGlassShelfWithdraw(Integer pageNum, Integer pageSize,List<String> selectDate, |
| | | FinishedGlassShelfWithdraw finishedGlassShelfWithdraw) throws JsonProcessingException { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(15).toString(); |
| | | if(selectDate !=null && selectDate.size()==2){ |
| | | if(!selectDate.get(0).isEmpty()){ |
| | | startDate = selectDate.get(0); |
| | | } |
| | | if(!selectDate.get(1).isEmpty()){ |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", finishedGlassShelfMapper.getSelectFinishedGlassShelfWithdraw(offset, pageSize,startDate,endDate, finishedGlassShelfWithdraw)); |
| | | map.put("total", finishedGlassShelfMapper.getSelectFinishedGlassShelfWithdrawPageTotal(offset, pageSize,startDate,endDate, finishedGlassShelfWithdraw)); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> getSelectFinishedGlassShelfWithdrawDetails(Integer pageNum, Integer pageSize, String withdrawId) { |
| | | if (withdrawId.startsWith("\"") && withdrawId.endsWith("\"")) { |
| | | withdrawId = withdrawId.substring(1, withdrawId.length() - 1); // 去除首尾引号 |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("withdraw", finishedGlassShelfMapper.getSelectFinishedGlassShelfWithdrawByemitId(withdrawId)); |
| | | map.put("data", finishedGlassShelfMapper.getSelectFinishedGlassShelfWithdrawDetailsBywithdrawId(withdrawId)); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | public String deleteFinishedGlassShelfWithdraw(Map<String,Object> object) { |
| | | String saveState = "true"; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | try { |
| | | String withdrawId = ""; |
| | | if (object.get("withdrawId") != null) { |
| | | withdrawId = object.get("withdrawId").toString(); |
| | | } |
| | | FinishedGlassShelfWithdraw finishedGlassShelfWithdraw2 = finishedGlassShelfMapper.getSelectFinishedGlassShelfWithdrawByemitId(withdrawId); |
| | | |
| | | if (finishedGlassShelfWithdraw2 != null) { |
| | | //编辑还原数据 |
| | | List<FinishedGlassShelfWithdrawDetails> finishedGlassShelfWithdrawDetailsList2 = finishedGlassShelfMapper |
| | | .getSelectFinishedGlassShelfWithdrawDetailsBywithdrawId1(withdrawId); |
| | | if (!finishedGlassShelfWithdrawDetailsList2.isEmpty()) { |
| | | for (FinishedGlassShelfWithdrawDetails finishedGlassShelfWithdrawDetails : finishedGlassShelfWithdrawDetailsList2) { |
| | | finishedGlassShelfMapper.updateEmitDetailsWithdrawQuantityOut(finishedGlassShelfWithdrawDetails); |
| | | finishedGlassShelfMapper.updateInformationAvailableQuantityOut( |
| | | finishedGlassShelfWithdrawDetails.getMaxWeight(), |
| | | finishedGlassShelfWithdrawDetails.getMaxWidth(), |
| | | finishedGlassShelfWithdrawDetails.getMaxHeight(), |
| | | finishedGlassShelfWithdrawDetails.getQuantity(), |
| | | finishedGlassShelfWithdrawDetails.getPrice(), |
| | | finishedGlassShelfWithdrawDetails.getUnit(), |
| | | finishedGlassShelfWithdrawDetails.getGlassShelfName() |
| | | ); |
| | | finishedGlassShelfMapper.deleteFinishedGlassShelfEmitDetailsLog(withdrawId); |
| | | } |
| | | |
| | | finishedGlassShelfMapper.deleteFinishedGlassShelfWithdrawDetails(withdrawId); |
| | | finishedGlassShelfMapper.deleteFinishedGlassShelfWithdraw(withdrawId); |
| | | getUpdateFinishedGlassShelfEmitState(finishedGlassShelfWithdrawDetailsList2.get(0).getEmitId()); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | Log log = new Log(); |
| | | log.setOperatorId(object.get("userId").toString()); |
| | | log.setOperator(object.get("userName").toString()); |
| | | log.setContent(object.toString()); |
| | | log.setFunction("deleteFinishedGlassShelfWithdraw删除:"+withdrawId); |
| | | logService.saveLog(log); |
| | | |
| | | return "true"; |
| | | }catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e+Arrays.toString(e.getStackTrace())); |
| | | sysError.setFunc("deleteFinishedGlassShelfWithdraw"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = "false"; |
| | | |
| | | } |
| | | return saveState; |
| | | |
| | | } |
| | | |
| | | |
| | | public Map<String, Object> getFinishedGlassShelfLogReport(String type,Integer pageNum, Integer pageSize, |
| | | List<String> selectDate, FinishedGlassShelfLog finishedGlassShelfLog) { |
| | | Integer offset = (pageNum-1)*pageSize; |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(15).toString(); |
| | | if(selectDate !=null && selectDate.size()==2){ |
| | | if(!selectDate.get(0).isEmpty()){ |
| | | startDate = selectDate.get(0); |
| | | } |
| | | if(!selectDate.get(1).isEmpty()){ |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | int state=0; |
| | | if(type.equals("料架出库")){ |
| | | state=1; |
| | | }else if(type.equals("料架入库")){ |
| | | state=2; |
| | | } |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | System.out.println(finishedGlassShelfLog.getDocumentId()); |
| | | map.put("data", finishedGlassShelfMapper.getFinishedGlassShelfLogReport(offset, pageSize,startDate, endDate, finishedGlassShelfLog,state)); |
| | | map.put("total", finishedGlassShelfMapper.getFinishedGlassShelfLogReportTotal(offset, pageSize,startDate, endDate, finishedGlassShelfLog,state)); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | return map; |
| | | } |
| | | |
| | | public List<FinishedGlassShelfLog> exportFinishedGlassShelfLogReport(List<LocalDate> dates, String type) { |
| | | int state=0; |
| | | if(type.equals("料架出库")){ |
| | | state=1; |
| | | }else if(type.equals("料架入库")){ |
| | | state=2; |
| | | } |
| | | return finishedGlassShelfMapper.exportFinishedGlassShelfLogReport(dates,state); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public String orderNumberSetting(String type) { |
| | | //根据类型自动生成不同的操作单号 |
| | | String alias=""; |
| | | Integer maximum=0; |
| | | if(Objects.equals(type, "入库")){ |
| | | alias="RK"; |
| | | maximum=finishedGlassShelfMapper.getmaximumWithdraw(); |
| | | }else if(Objects.equals(type, "出库")){ |
| | | alias="CK"; |
| | | maximum=finishedGlassShelfMapper.getmaximumEmit(); |
| | | } |
| | | //设置两位不够补0 |
| | | String formattedNumber = String.format("%02d", maximum+1); |
| | | //格式化当前日期 |
| | | Date currentDate = new Date(); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMdd"); |
| | | String formattedDate = dateFormat.format(currentDate); |
| | | String oddNumbers = alias+formattedDate+formattedNumber; |
| | | return oddNumbers; |
| | | } |
| | | |
| | | |
| | | } |