#
whycq
2022-09-13 35ddd989b73d815777055bcdf05118d6cdd892e6
src/main/java/zy/cloud/wms/manager/controller/ItemController.java
@@ -19,6 +19,7 @@
import zy.cloud.wms.manager.service.*;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
@RestController
@@ -32,6 +33,8 @@
    private FlowStatusService flowStatusService;
    @Autowired
    private CstmrService cstmrService;
    @Autowired
    private ProjectStatusService projectStatusService;
    @RequestMapping(value = "/item/{id}/auth")
    @ManagerAuth
@@ -113,6 +116,7 @@
        /**
         * 控管
         */
        if (Cools.isEmpty(item)) {
            return R.error("参数为空,请联系管理员");
        }
@@ -126,27 +130,32 @@
        if (!Cools.isEmpty(name)) {
            throw new CoolException("不可有重复项目名");
        }
        if (item.getRealMonth() < 0){
            throw new CoolException("实施周期不可为负数");
        }
//        if (item.getRealMonth() < 0){
//            throw new CoolException("实施周期不可为负数");
//        }
        if (Cools.isEmpty(item.getCstmrUuid())) {
            throw new CoolException("请选择客户");
        }
        Cstmr cstmr = cstmrService.selectOne(new EntityWrapper<Cstmr>()
                .eq("id",Long.parseLong(item.getUuid())));
                .eq("id",Long.parseLong(item.getCstmrUuid())));
        if (Cools.isEmpty(cstmr)) {
            throw new CoolException("找不到该客户,请检查");
        }
        item.setCustMan(cstmr.getName());
        item.setCustMobile(cstmr.getTel());
        item.setCustAdress(cstmr.getAddr());
        item.setHostId(getHostId());
        if (Cools.isEmpty(item.getHostId()) || item.getHostId() == 0){
            item.setHostId(1L);
        }else {
            item.setHostId(getHostId());
        }
        item.setCreateBy(getUserId());
        item.setCreateTime(new Date());
        item.setStatus(1);
        item.setUpdateBy(getUserId());
        item.setUpdateTime(new Date());
        Long span = (item.getEndTime().getTime() - item.getStartTime().getTime()) / 1000 / 60 / 60 / 24;
        item.setRealMonth(Math.toIntExact(span));
        itemService.insertAll(item);
        return R.ok();
    }
@@ -159,6 +168,7 @@
        if (Cools.isEmpty(item)) {
            return R.error("参数为空,请联系管理员");
        }
//        item.setType("1");
//        if (!item.getType().equals("1")) {
//            throw new CoolException("目前仅支持集成项目");
@@ -167,12 +177,17 @@
//        if (item.getRealMonth() < 0){
//            throw new CoolException("实施周期不可为负数");
//        }
        if(!(newitem.getStartTime()==null || newitem.getEndTime()==null || newitem.getRealStartTime()==null || newitem.getRealEndTime()==null)){
            item.setStartTime(newitem.getStartTime());
            item.setEndTime(newitem.getEndTime());
            item.setRealEndTime(newitem.getRealEndTime());
            item.setRealStartTime(newitem.getRealStartTime());
        }
        //↓↓↓写这段代码的真该抽大嘴巴子
//        if(!(newitem.getStartTime()==null || newitem.getEndTime()==null || newitem.getRealStartTime()==null || newitem.getRealEndTime()==null)){
//            item.setStartTime(newitem.getStartTime());
//            item.setEndTime(newitem.getEndTime());
//            item.setRealEndTime(newitem.getRealEndTime());
//            item.setRealStartTime(newitem.getRealStartTime());
//        }
        //超出运费
        if(item.getPlandeAmt()!=null && item.getRealdeAmt()!=null){
            item.setExcessAmount(item.getRealdeAmt()-item.getPlandeAmt());
@@ -284,5 +299,19 @@
        return R.ok();
    }
    @RequestMapping(value = "/progressRate/auth")
    @ManagerAuth
    public R queryProgressRate(String condition) {
        List<Map<String, Object>> result = new ArrayList<>();
        List<ProjectStatus> projectStatuses = projectStatusService.selectList(null);
        for (ProjectStatus projectStatus : projectStatuses) {
            Map<String, Object> map = new HashMap<>();
            map.put("id", projectStatus.getId());
            map.put("value", projectStatus.getStatusName());
            result.add(map);
        }
        return R.ok(result);
    }
}