| | |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.apache.shiro.subject.Subject; |
| | |
| | | import org.jeecg.modules.flowable.apithird.service.FlowCommonService; |
| | | import org.jeecg.modules.flowable.service.IFlowDefinitionService; |
| | | import org.jeecg.modules.flowable.service.IFlowTaskService; |
| | | import org.jeecg.modules.tms.entity.InboundOrder; |
| | | import org.jeecg.modules.tms.entity.*; |
| | | import org.jeecg.modules.tms.entity.dto.InboundOrderFlowDto; |
| | | import org.jeecg.modules.tms.entity.vo.InboundDetailVo; |
| | | import org.jeecg.modules.tms.mapper.InboundOrderMapper; |
| | | import org.jeecg.modules.tms.service.IInboundOrderService; |
| | | import org.jeecg.modules.tms.service.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private IFlowMyBusinessService flowMyBusinessService; |
| | | |
| | | @Autowired |
| | | private IBaseToolsService baseToolsService; |
| | | |
| | | @Autowired |
| | | private IInStoreDetailService inStoreDetailService; |
| | | |
| | | @Autowired |
| | | private IToolLedgerService toolLedgerService; |
| | | |
| | | @Autowired |
| | | private IToolLedgerDetailService toolLedgerDetailService; |
| | | @Override |
| | | public boolean submit(String id) { |
| | | InboundOrder inboundOrder = this.getById(id); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void addInStorage(JSONObject jSONObject) { |
| | | String inStorehouseType = jSONObject.getString("inStorehouseType"); |
| | | Date inboundTime = jSONObject.getDate("inboundTime"); |
| | | //获取入库明细 |
| | | JSONArray jsonArray = jSONObject.getJSONArray("detailData"); |
| | | List<InboundDetailVo> inStoreDetailList =jsonArray.toJavaList(InboundDetailVo.class); |
| | | //新货入库 |
| | | if("1".equals(inStorehouseType)){ |
| | | //循环新增明细 |
| | | for(InboundDetailVo inboundDetailVo : inStoreDetailList){ |
| | | //查询是否管到把,管到把的查询当前编码 |
| | | BaseTools baseTools = baseToolsService.getById(inboundDetailVo.getToolCodeId()); |
| | | //操作库存,查询总库存是否存在该类刀具 |
| | | ToolLedger toolLedger = toolLedgerService.lambdaQuery().eq(ToolLedger::getToolId,inboundDetailVo.getToolCodeId()).one(); |
| | | if(toolLedger == null){ |
| | | ToolLedger newToolLedger = new ToolLedger(); |
| | | newToolLedger.setToolId(inboundDetailVo.getToolCodeId()); |
| | | newToolLedger.setAvailableCount(inboundDetailVo.getInStorageQuantity()); |
| | | newToolLedger.setTotalCount(inboundDetailVo.getInStorageQuantity()); |
| | | newToolLedger.setLendCount(BigDecimal.ZERO); |
| | | newToolLedger.setDetectionCount(BigDecimal.ZERO); |
| | | newToolLedger.setLossCount(BigDecimal.ZERO); |
| | | newToolLedger.setRepairCount(BigDecimal.ZERO); |
| | | newToolLedger.setSharpeningCount(BigDecimal.ZERO); |
| | | toolLedgerService.save(newToolLedger); |
| | | }else { |
| | | toolLedger.setAvailableCount(toolLedger.getAvailableCount().add(inboundDetailVo.getInStorageQuantity())); |
| | | toolLedger.setTotalCount(toolLedger.getTotalCount().add(inboundDetailVo.getInStorageQuantity())); |
| | | toolLedgerService.updateById(toolLedger); |
| | | } |
| | | //管到把 |
| | | if("1".equals(baseTools.getAccuracyClass())){ |
| | | //循环入库数量,为实物赋码 |
| | | for(int i=0;i<inboundDetailVo.getInStorageQuantity().intValue();i++){ |
| | | BaseTools newBaseTools = baseToolsService.getById(inboundDetailVo.getToolCodeId()); |
| | | //查询当前编码 |
| | | String currentCode = newBaseTools.getCurrentCode(); |
| | | //将字符串转换为整数 |
| | | int num = Integer.parseInt(currentCode); |
| | | //加1操作 |
| | | num++; |
| | | //转换回字符串并保留前导零 |
| | | String result = String.format("%0" + currentCode.length() + "d", num); |
| | | //保存入库流水 |
| | | InStoreDetail inStoreDetail = new InStoreDetail(); |
| | | inStoreDetail.setInboundTime(inboundTime); |
| | | inStoreDetail.setOperateType("2"); |
| | | inStoreDetail.setInNumber(BigDecimal.ONE); |
| | | inStoreDetail.setInStorehouseType("1"); |
| | | inStoreDetail.setToolCode(inboundDetailVo.getToolCodeId()); |
| | | inStoreDetail.setToolId(inboundDetailVo.getToolCode()+"-"+result); |
| | | inStoreDetailService.save(inStoreDetail); |
| | | //增加库存明细 |
| | | ToolLedgerDetail toolLedgerDetail = new ToolLedgerDetail(); |
| | | toolLedgerDetail.setToolCode(inboundDetailVo.getToolCodeId()); |
| | | toolLedgerDetail.setToolId(inboundDetailVo.getToolCode()+"-"+result); |
| | | toolLedgerDetail.setQuantity(BigDecimal.ONE); |
| | | toolLedgerDetail.setStatus("1"); |
| | | toolLedgerDetailService.save(toolLedgerDetail); |
| | | //更新当前编码 |
| | | newBaseTools.setCurrentCode(result); |
| | | baseToolsService.updateById(newBaseTools); |
| | | } |
| | | //不管到把 |
| | | }else { |
| | | //保存入库流水 |
| | | InStoreDetail inStoreDetail = new InStoreDetail(); |
| | | inStoreDetail.setInboundTime(inboundTime); |
| | | inStoreDetail.setOperateType("2"); |
| | | inStoreDetail.setInNumber(inboundDetailVo.getInStorageQuantity()); |
| | | inStoreDetail.setInStorehouseType("1"); |
| | | inStoreDetail.setToolCode(inboundDetailVo.getToolCodeId()); |
| | | inStoreDetailService.save(inStoreDetail); |
| | | //查询库存明细中是否存在该工具 |
| | | ToolLedgerDetail toolLedgerDetail = toolLedgerDetailService.lambdaQuery().eq(ToolLedgerDetail::getToolCode,inboundDetailVo.getToolCodeId()).one(); |
| | | if(toolLedgerDetail == null){ |
| | | ToolLedgerDetail newToolLedgerDetail = new ToolLedgerDetail(); |
| | | newToolLedgerDetail.setToolCode(inboundDetailVo.getToolCodeId()); |
| | | newToolLedgerDetail.setQuantity(inboundDetailVo.getInStorageQuantity()); |
| | | newToolLedgerDetail.setStatus("1"); |
| | | toolLedgerDetailService.save(newToolLedgerDetail); |
| | | }else { |
| | | toolLedgerDetail.setQuantity(toolLedgerDetail.getQuantity().add(inboundDetailVo.getInStorageQuantity())); |
| | | toolLedgerDetailService.updateById(toolLedgerDetail); |
| | | } |
| | | } |
| | | } |
| | | }else if("2".equals(inStorehouseType)){ |
| | | |
| | | }else if("5".equals(inStorehouseType)){ |
| | | |
| | | } |
| | | } |
| | | |
| | | private LoginUser getCurrentUser() { |
| | | // 获取当前认证的登录用户信息 |
| | | Subject currentUser = SecurityUtils.getSubject(); |