#
mrzhssss
2022-04-07 501fde46aac0cd02a6b7fe61cddfe1d08cfe8d1e
src/main/java/zy/cloud/wms/manager/controller/ItemController.java
@@ -15,15 +15,10 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import zy.cloud.wms.common.web.BaseController;
import zy.cloud.wms.manager.entity.Cstmr;
import zy.cloud.wms.manager.entity.Item;
import zy.cloud.wms.manager.entity.ProjectPlan;
import zy.cloud.wms.manager.entity.ProjectType;
import zy.cloud.wms.manager.service.CstmrService;
import zy.cloud.wms.manager.service.ItemService;
import zy.cloud.wms.manager.service.ProjectPlanService;
import zy.cloud.wms.manager.service.ProjectTypeService;
import zy.cloud.wms.manager.entity.*;
import zy.cloud.wms.manager.service.*;
import java.text.SimpleDateFormat;
import java.util.*;
@RestController
@@ -33,6 +28,12 @@
    private ItemService itemService;
    @Autowired
    private ProjectPlanService planService;
    @Autowired
    private FlowStatusService flowStatusService;
    @Autowired
    private CstmrService cstmrService;
    @Autowired
    private ProjectStatusService projectStatusService;
    @RequestMapping(value = "/item/{id}/auth")
    @ManagerAuth
@@ -46,11 +47,13 @@
                  @RequestParam(defaultValue = "10")Integer limit,
                  @RequestParam(required = false)String orderByField,
                  @RequestParam(required = false)String orderByType,
                  @RequestParam(required = false)String condition,
                  @RequestParam Map<String, Object> param){
        EntityWrapper<Item> wrapper = new EntityWrapper<>();
        HashSet<String> excludeField = new HashSet<>();
        allLike(Item.class,excludeField,wrapper, (String) param.get("id"));
        allLike(Item.class, param.keySet(), wrapper, condition);
//        allLike(Item.class,excludeField,wrapper, (String) param.get("id"));
        excludeTrash(param);
        convert(param, wrapper);
        hostEq(wrapper);
@@ -109,10 +112,13 @@
    @RequestMapping(value = "/item/add/auth")
    @ManagerAuth
    public R add(Item item) {
        /**
         * 控管
         */
        if (Cools.isEmpty(item)) {
            return R.error("参数为空,请联系管理员");
        }
        //item.setType("1");
//        if (!item.getType().equals("1")) {
//            throw new CoolException("目前仅支持集成项目");
@@ -125,7 +131,18 @@
        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())));
        if (Cools.isEmpty(cstmr)) {
            throw new CoolException("找不到该客户,请检查");
        }
        item.setCustMan(cstmr.getName());
        item.setCustMobile(cstmr.getTel());
        item.setCustAdress(cstmr.getAddr());
        item.setHostId(getHostId());
        item.setCreateBy(getUserId());
        item.setCreateTime(new Date());
@@ -157,6 +174,16 @@
            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());
        }
        //超出天数
        if(item.getRealinDate()!=null && item.getPlaninDate()!=null){
            Double days = (double) ((item.getRealinDate().getTime() - item.getPlaninDate().getTime()) / (1000*3600*24));
            Integer day= (int) Math.ceil(days);
            item.setExcessTime(day);
        }
        item.setUpdateBy(getUserId());
        item.setUpdateTime(new Date());
@@ -228,4 +255,50 @@
        return R.ok();
    }
    /**
     * 初始化生成项目节点
     * @param param
     * @return
     */
    @RequestMapping(value = "/item/initPlan/auth")
    @ManagerAuth
    public R initPlan(@RequestParam("id") String param){
        if (param != null){
            List<ProjectPlan> projectPlans = planService.selectList(new EntityWrapper<ProjectPlan>().eq("item_id",param));
            if(!Cools.isEmpty(projectPlans) && projectPlans.size()>0){
                return R.error("该项目已有节点计划");
            }
            List<FlowStatus> flowStatuses = flowStatusService.selectList(new EntityWrapper<FlowStatus>());
            if(!Cools.isEmpty(flowStatuses) && flowStatuses.size()>0){
                for(FlowStatus flowStatus : flowStatuses){
                    ProjectPlan projectPlan = new ProjectPlan();
                    projectPlan.setItemId(Long.parseLong(param));
                    projectPlan.setWeightNum(flowStatus.getWeightNum());
                    projectPlan.setFlowId(flowStatus.getId());
                    planService.insert(projectPlan);
                }
            } else {
                return R.error("项目计划节点基础数据为空");
            }
        } else {
            return R.error("项目参数错误");
        }
        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);
    }
}