| | |
| | | import com.zy.asrs.service.MatService; |
| | | import com.zy.asrs.service.TagService; |
| | | import com.zy.ints.entity.Prdt; |
| | | import com.zy.ints.entity.PrdtBak; |
| | | import com.zy.ints.erp.ErpSqlServer; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private ErpSqlServer erpSqlServer; |
| | | @Autowired |
| | | private MatService matService; |
| | | |
| | | /** |
| | | * 获取商品信息表资料 |
| | | */ |
| | |
| | | String sqlSelectPrdt = "select prd_no as prdNo,name,ut,spc,type,status from erp_prdt where 1=1"; |
| | | String sqlUpDatePrdtOne = "update erp_prdt set status=1 where prd_no="; |
| | | String sqlUpDatePrdtTwo = "update erp_prdt set status=2 where prd_no="; |
| | | Tag tag = tagService.selectByName("全部", 1); |
| | | try { |
| | | Tag tag = tagService.selectByName("全部", 1); |
| | | |
| | | List<Prdt> prdts = erpSqlServer.select(sqlSelectPrdt,Prdt.class); |
| | | if (prdts.size() > 0){ |
| | | for (Prdt prdt : prdts) { |
| | | Date date = new Date(); |
| | | if (prdt.getStatus()==0) { |
| | | Integer type = prdt.getType(); |
| | | if (type==1){ |
| | | Mat mat = matService.selectByMatnr(prdt.getPrdNo()); |
| | | if (Cools.isEmpty(mat)){ |
| | | Mat matNew = new Mat(); |
| | | matNew.setTagId(tag.getId()); |
| | | matNew.setMatnr(prdt.getPrdNo()); |
| | | matNew.setMaktx(prdt.getName()); |
| | | matNew.setUnit(prdt.getUt()); |
| | | matNew.setSpecs(prdt.getSpc()); |
| | | matNew.setCreateBy(9999L); |
| | | matNew.setCreateTime(date); |
| | | matNew.setUpdateBy(9999L); |
| | | matNew.setUpdateTime(date); |
| | | if (matService.insert(matNew)){ |
| | | erpSqlServer.update(sqlUpDatePrdtOne+"'" + prdt.getPrdNo() + "'"); |
| | | }else { |
| | | erpSqlServer.update(sqlUpDatePrdtTwo+"'" + prdt.getPrdNo() + "'"); |
| | | List<Prdt> prdts = erpSqlServer.select(sqlSelectPrdt, Prdt.class); |
| | | if (prdts.size() > 0) { |
| | | for (Prdt prdt : prdts) { |
| | | Date date = new Date(); |
| | | if (prdt.getStatus() == 0) { |
| | | Integer type = prdt.getType(); |
| | | if (type == 1) { |
| | | Mat mat = matService.selectByMatnr(prdt.getPrdNo()); |
| | | if (Cools.isEmpty(mat)) { |
| | | Mat matNew = new Mat(); |
| | | matNew.setTagId(tag.getId()); |
| | | matNew.setMatnr(prdt.getPrdNo()); |
| | | matNew.setMaktx(prdt.getName()); |
| | | matNew.setUnit(prdt.getUt()); |
| | | matNew.setSpecs(prdt.getSpc()); |
| | | matNew.setCreateBy(9999L); |
| | | matNew.setCreateTime(date); |
| | | matNew.setUpdateBy(9999L); |
| | | matNew.setUpdateTime(date); |
| | | if (matService.insert(matNew)) { |
| | | erpSqlServer.update(sqlUpDatePrdtOne + "'" + prdt.getPrdNo() + "'"); |
| | | } else { |
| | | erpSqlServer.update(sqlUpDatePrdtTwo + "'" + prdt.getPrdNo() + "'"); |
| | | } |
| | | } |
| | | } |
| | | }else if (type==2){ |
| | | Mat mat = matService.selectByMatnr(prdt.getPrdNo()); |
| | | if (!Cools.isEmpty(mat)){ |
| | | mat.setMaktx(prdt.getName()); |
| | | mat.setUnit(prdt.getUt()); |
| | | mat.setSpecs(prdt.getSpc()); |
| | | if (matService.updateById(mat)){ |
| | | erpSqlServer.update(sqlUpDatePrdtOne+"'" + prdt.getPrdNo() + "'"); |
| | | }else { |
| | | erpSqlServer.update(sqlUpDatePrdtTwo+"'" + prdt.getPrdNo() + "'"); |
| | | } else if (type == 2) { |
| | | Mat mat = matService.selectByMatnr(prdt.getPrdNo()); |
| | | if (!Cools.isEmpty(mat)) { |
| | | mat.setMaktx(prdt.getName()); |
| | | mat.setUnit(prdt.getUt()); |
| | | mat.setSpecs(prdt.getSpc()); |
| | | if (matService.updateById(mat)) { |
| | | erpSqlServer.update(sqlUpDatePrdtOne + "'" + prdt.getPrdNo() + "'"); |
| | | } else { |
| | | erpSqlServer.update(sqlUpDatePrdtTwo + "'" + prdt.getPrdNo() + "'"); |
| | | } |
| | | } |
| | | } |
| | | }else if (type==3){ |
| | | Mat mat = matService.selectByMatnr(prdt.getPrdNo()); |
| | | if (!Cools.isEmpty(mat)){ |
| | | if (matService.deleteById(mat.getId())){ |
| | | erpSqlServer.update(sqlUpDatePrdtOne+"'" + prdt.getPrdNo() + "'"); |
| | | }else { |
| | | erpSqlServer.update(sqlUpDatePrdtTwo+"'" + prdt.getPrdNo() + "'"); |
| | | } else if (type == 3) { |
| | | Mat mat = matService.selectByMatnr(prdt.getPrdNo()); |
| | | if (!Cools.isEmpty(mat)) { |
| | | if (matService.deleteById(mat.getId())) { |
| | | erpSqlServer.update(sqlUpDatePrdtOne + "'" + prdt.getPrdNo() + "'"); |
| | | } else { |
| | | erpSqlServer.update(sqlUpDatePrdtTwo + "'" + prdt.getPrdNo() + "'"); |
| | | } |
| | | } |
| | | } else { |
| | | |
| | | } |
| | | }else { |
| | | } else if (prdt.getStatus() == 1) { |
| | | HashMap<String, Object> condition = new HashMap<>(); |
| | | condition.put("prd_no", "'" + prdt.getPrdNo() + "'"); |
| | | condition.put("name", "'" + prdt.getName() + "'"); |
| | | condition.put("ut", "'" + prdt.getUt() + "'"); |
| | | condition.put("spc", "'" + prdt.getSpc() + "'"); |
| | | condition.put("type", "'" + prdt.getType() + "'"); |
| | | condition.put("status", "'" + prdt.getStatus() + "'"); |
| | | erpSqlServer.insert(PrdtBak.class, condition); |
| | | |
| | | HashMap<String, String> condition2 = new HashMap<>(); |
| | | condition2.put("prd_no", "'" + prdt.getPrdNo() + "'"); |
| | | erpSqlServer.delete(Prdt.class, condition2); |
| | | } else if (prdt.getStatus() == 2) { |
| | | |
| | | } else { |
| | | |
| | | } |
| | | }else if (prdt.getStatus()==1){ |
| | | // HashMap<String, Object> condition = new HashMap<>(); |
| | | // condition.put("prd_no","'" + prdt.getPrdNo() + "'"); |
| | | // condition.put("name","'" + prdt.getName() + "'"); |
| | | // condition.put("ut","'" + prdt.getUt() + "'"); |
| | | // condition.put("spc","'" + prdt.getSpc() + "'"); |
| | | // condition.put("type","'" + prdt.getType() + "'"); |
| | | // condition.put("status","'" + prdt.getStatus() + "'"); |
| | | // erpSqlServer.insert(Prdt.class, condition); |
| | | // |
| | | // HashMap<String, String> condition2 = new HashMap<>(); |
| | | // condition2.put("prd_no","'" + prdt.getPrdNo() + "'"); |
| | | // erpSqlServer.delete(Prdt.class,condition2); |
| | | }else if (prdt.getStatus()==2){ |
| | | |
| | | }else { |
| | | |
| | | } |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | |
| | | } |