| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | import zy.cloud.wms.common.model.BillDto; |
| | | import zy.cloud.wms.common.service.erp.ErpService; |
| | | import zy.cloud.wms.common.web.BaseController; |
| | | import zy.cloud.wms.manager.entity.LocSum; |
| | | import zy.cloud.wms.manager.entity.Pakin; |
| | | import zy.cloud.wms.manager.entity.WrkLocSync; |
| | | import zy.cloud.wms.manager.service.LocSyncService; |
| | | import zy.cloud.wms.manager.service.WrkLocSyncService; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static jdk.nashorn.api.scripting.ScriptUtils.convert; |
| | | |
| | | @RestController |
| | | @Slf4j |
| | |
| | | |
| | | @RequestMapping(value = "/locSync/insertWrklocSync") |
| | | @ManagerAuth(memo = "同步上传清单数据插入") |
| | | @Transactional |
| | | public R insertWrklocSync(@RequestBody JSONObject param) { |
| | | Date now = new Date(); |
| | | Long userId = getUserId(); |
| | | List<WrkLocSync> list = JSONObject.parseArray(param.getJSONArray("list").toJSONString(), WrkLocSync.class); |
| | | // 插入创建人员和创建时间 |
| | | if (list.size() > 0) { |
| | | for (WrkLocSync elist : list) { |
| | | elist.setCreateBy(getUserId()); |
| | | elist.setCreateTime(new Date()); |
| | | for (WrkLocSync wrkLocSync : list) { |
| | | WrkLocSync sync = new WrkLocSync(); |
| | | sync.setMatnr(wrkLocSync.getMatnr()); |
| | | sync.setQty(wrkLocSync.getQty()); |
| | | sync.setState("N"); |
| | | sync.setCreateTime(now); |
| | | sync.setCreateBy(userId); |
| | | sync.setUpdateBy(userId); |
| | | sync.setUpdateTime(now); |
| | | if (!wrkLocSyncService.insert(sync)) { |
| | | throw new CoolException("同步失败"); |
| | | } |
| | | |
| | | } |
| | | Integer result = 0; |
| | | result = wrkLocSyncService.insertWrkLocSync(list); |
| | | return R.ok(result); |
| | | return R.ok(list.size()); |
| | | } |
| | | |
| | | |
| | |
| | | res.setMatnr(executeData.getMatnr()); |
| | | res.setQty(executeData.getQty()); |
| | | dtos.add(res); |
| | | if (erpService.uploadBill(dtos, docId, docNum)) { |
| | | if (erpService.uploadBill(dtos, docId, docNum).getSuccess()) { |
| | | // 成功后删除任务 |
| | | if (!wrkLocSyncService.delete(new EntityWrapper<WrkLocSync>().eq("matnr", executeData.getMatnr()))) { |
| | | log.info("库存同步删除任务失败,任务matnr=" + executeData.getMatnr() + "时间=" + new Date()); |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | @RequestMapping(value = "/locsync/export/auth") |
| | | @ManagerAuth |
| | | public R export(@RequestBody JSONObject param){ |
| | | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); |
| | | List<LocSum> locSums = locSyncService.queryLocSum(); |
| | | return R.ok(exportSupport(locSums, fields)); |
| | | } |
| | | } |