| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.example.erp.entity.pp.BasicDataProduce; |
| | | import com.example.erp.entity.pp.FlowCard; |
| | | import com.example.erp.entity.pp.Rework; |
| | | import com.example.erp.entity.sd.Delivery; |
| | | import com.example.erp.entity.sd.OrderDetail; |
| | | import com.example.erp.entity.userInfo.SysError; |
| | | import com.example.erp.mapper.pp.BasicDateProduceMapper; |
| | | import com.example.erp.mapper.pp.ReworkMapper; |
| | | import com.example.erp.mapper.pp.*; |
| | | import com.example.erp.service.userInfo.SysErrorService; |
| | | 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 com.example.erp.mapper.pp.FlowCardMapper; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | |
| | | |
| | | @Service |
| | | @DS("pp") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public class ReworkService { |
| | | @Autowired |
| | | PatchLogMapper patchMapper; |
| | | @Autowired |
| | | ReworkMapper reworkMapper; |
| | | @Autowired |
| | |
| | | @Autowired |
| | | SysErrorService sysErrorService; |
| | | |
| | | final |
| | | FlowCardMapper flowCardMapper; |
| | | |
| | | public ReworkService(FlowCardMapper flowCardMapper) { |
| | | this.flowCardMapper = flowCardMapper; |
| | | } |
| | | |
| | | public List<Map<String, Object>> getSelectRework(Integer pageNum, Integer pageSize) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | |
| | | |
| | | |
| | | List<Map<String, Object>> ReworkMap =reworkMapper.getSelectRework(offset,pageSize); |
| | | List<BasicDataProduce> basicDataProduceList=basicDateProduceMapper.SelectWorkBasicTeams(); |
| | | |
| | | |
| | | for (Map<String, Object> item:ReworkMap){ |
| | | item.put("reworkTeam",""); |
| | | List<BasicDataProduce> basicCategory=new ArrayList<>(); |
| | | |
| | | List<BasicDataProduce> basicDataProduceList=basicDateProduceMapper.SelectWorkBasicTeams(item.get("reworkProcesses").toString()); |
| | | for (BasicDataProduce basicDataProduce:basicDataProduceList){ |
| | | if(Objects.equals(basicDataProduce.getBasicData().getBasicName(),item.get("reworkProcesses"))){ |
| | | basicCategory.add(basicDataProduce); |
| | |
| | | } |
| | | item.put("basicCategory",basicCategory); |
| | | listMap.add(item); |
| | | System.out.println(listMap); |
| | | } |
| | | return listMap; |
| | | } |
| | |
| | | |
| | | public Boolean saveRework(Map<String,Object> object) { |
| | | boolean saveState = true; |
| | | |
| | | |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | try { |
| | | String userName = ""; |
| | | String userId = ""; |
| | | if (object.get("userName") != null) { |
| | |
| | | if (object.get("userId") != null) { |
| | | userId = object.get("userId").toString(); |
| | | } |
| | | //获取单号 |
| | | String oddNumber= orderNumberSetting("返工"); |
| | | //获取对象集合循环进行新增修改 |
| | | List<Rework> reworklist = JSONArray.parseArray(JSONObject.toJSONString(object.get("rework")), Rework.class); |
| | | if (!reworklist.isEmpty()){ |
| | | for (Rework rework : reworklist) { |
| | | System.out.println(rework); |
| | | //获取单号 |
| | | String oddNumber= orderNumberSetting("返工"); |
| | | //添加出入库记录 |
| | | //添加返工记录,修改次破明细数量 |
| | | reworkMapper.insertRework(rework,oddNumber); |
| | | reworkMapper.updateReportingWorkDetail(rework); |
| | | reworkMapper.updateDamageDetails(rework); |
| | | patchMapper.updateReportingWorkDetail(rework.getReportingWorkId(), Integer.valueOf(rework.getOrderSort()),rework.getTechnologyNumber()); |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e.toString()); |
| | | sysError.setFunc("saveOrder"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = false; |
| | | |
| | | } |
| | | |
| | | return saveState; |
| | | |
| | |
| | | String oddNumbers = alias+formattedDate+formattedNumber; |
| | | return oddNumbers; |
| | | } |
| | | |
| | | public Object selectPrintSv(java.sql.Date selectTime1, java.sql.Date selectTime2, FlowCard flowCard) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", flowCardMapper.selectReworkPrintMp(selectTime1,selectTime2,flowCard)); |
| | | map.put("type", flowCardMapper.selectType()); |
| | | return map; |
| | | } |
| | | } |
| | | |