mrzhssss
2022-01-12 5b53ccc3d0e46773c3fa58751935df331d562af4
src/main/java/zy/cloud/wms/manager/controller/ItemController.java
@@ -10,14 +10,17 @@
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.R;
import com.core.exception.CoolException;
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 java.util.*;
@@ -28,9 +31,7 @@
    @Autowired
    private ItemService itemService;
    @Autowired
    private CstmrService cstmrService;
    @Autowired
    private ProjectTypeService projectTypeService;
    private ProjectPlanService planService;
    @RequestMapping(value = "/item/{id}/auth")
    @ManagerAuth
@@ -49,6 +50,7 @@
        excludeTrash(param);
        convert(param, wrapper);
        hostEq(wrapper);
        wrapper.orderBy("status",false);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
        return R.ok(itemService.selectPage(new Page<>(curr, limit), wrapper));
    }
@@ -73,19 +75,14 @@
        if (Cools.isEmpty(item)) {
            return R.error("参数为空,请联系管理员");
        }
        Cstmr user_code = cstmrService.selectOne(new EntityWrapper<Cstmr>()
                .eq("user_code", item.getCstmrUuid()));
        if (!Cools.isEmpty(user_code)) {
            item.setCstmr(user_code.getName());
        }else {
            return R.error("参数错误,请输入正确的客户编号");
        if (!item.getType().equals("1")) {
            throw new CoolException("目前仅支持集成项目");
        }
        ProjectType id = projectTypeService.selectOne(new EntityWrapper<ProjectType>()
                .eq("id", item.getType()));
        if (!Cools.isEmpty(id)) {
            item.setType(id.getTypeName());
        }else {
            return R.error("参数错误,找不到该项目类型");
        Item name = itemService.selectOne(new EntityWrapper<Item>()
                .eq("name", item.getName()));
        if (!Cools.isEmpty(name)) {
            throw new CoolException("不可有重复项目名");
        }
        item.setHostId(getHostId());
@@ -94,7 +91,7 @@
        item.setStatus(1);
        item.setUpdateBy(getUserId());
        item.setUpdateTime(new Date());
        itemService.insert(item);
        itemService.insertAll(item);
        return R.ok();
    }
@@ -104,23 +101,10 @@
        if (Cools.isEmpty(item)) {
            return R.error("参数为空,请联系管理员");
        }
        Cstmr user_code = cstmrService.selectOne(new EntityWrapper<Cstmr>()
                .eq("user_code", item.getCstmrUuid()));
        if (!Cools.isEmpty(user_code)) {
            item.setCstmr(user_code.getName());
        }else {
            return R.error("参数错误,请输入正确的客户编号");
        if (!item.getType().equals("1")) {
            throw new CoolException("目前仅支持集成项目");
        }
        ProjectType id = projectTypeService.selectOne(new EntityWrapper<ProjectType>()
                .eq("id", item.getType()));
        if (!Cools.isEmpty(id)) {
            item.setType(id.getTypeName());
        }else {
            return R.error("参数错误,找不到该项目类型");
        }
//        if (Cools.isEmpty(item) || null==item.getUuid()){
//            return R.error();
//        }
        item.setUpdateBy(getUserId());
        item.setUpdateTime(new Date());
        itemService.updateById(item);
@@ -130,10 +114,14 @@
    @RequestMapping(value = "/item/delete/auth")
    @ManagerAuth
    public R delete(@RequestParam("ids[]") String param){
        if (param != null){
            itemService.delete(new EntityWrapper<Item>()
                    .eq("id",param));
            planService.delete(new EntityWrapper<ProjectPlan>()
                    .eq("item_id",param));
        }
//        List<Item> list = JSONArray.parseArray(param, Item.class);
//        if (Cools.isEmpty(list)){
//            return R.error();