From 964c095a69cc70115b6c5c185c0682aeb68da5ab Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期一, 12 九月 2022 14:47:27 +0800
Subject: [PATCH] #
---
src/main/java/zy/cloud/wms/manager/controller/ItemController.java | 204 +++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 190 insertions(+), 14 deletions(-)
diff --git a/src/main/java/zy/cloud/wms/manager/controller/ItemController.java b/src/main/java/zy/cloud/wms/manager/controller/ItemController.java
index 61ae10b..b654267 100644
--- a/src/main/java/zy/cloud/wms/manager/controller/ItemController.java
+++ b/src/main/java/zy/cloud/wms/manager/controller/ItemController.java
@@ -10,12 +10,15 @@
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.R;
+import com.core.exception.CoolException;
+import lombok.val;
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.Item;
-import zy.cloud.wms.manager.service.ItemService;
+import zy.cloud.wms.manager.entity.*;
+import zy.cloud.wms.manager.service.*;
+import java.text.SimpleDateFormat;
import java.util.*;
@RestController
@@ -23,6 +26,14 @@
@Autowired
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
@@ -36,11 +47,18 @@
@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, param.keySet(), wrapper, condition);
+// allLike(Item.class,excludeField,wrapper, (String) param.get("id"));
excludeTrash(param);
convert(param, wrapper);
hostEq(wrapper);
+// wrapper.orderBy("status",true);
+ wrapper.orderBy("id",false);
if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
return R.ok(itemService.selectPage(new Page<>(curr, limit), wrapper));
}
@@ -58,40 +76,152 @@
}
}
+ @RequestMapping(value = "/item/list/chaoPirce")
+ @ManagerAuth
+ public R list1(@RequestParam(defaultValue = "1")Integer curr,
+ @RequestParam(defaultValue = "10")Integer limit,
+ @RequestParam(required = false)String orderByField,
+ @RequestParam(required = false)String orderByType,
+ @RequestParam Map<String, Object> param){
+ val id = param.get("id");
+ String uuid=null;
+ if(id!=null){
+ uuid = id.toString();
+ }
+ Page<Item> projectPlanPage = itemService.chaoPirce(toPage(curr,limit,param,Item.class),uuid);
+ return R.ok(projectPlanPage);
+ }
+
+ @RequestMapping(value = "/item/list/chaoTime")
+ @ManagerAuth
+ public R list2(@RequestParam(defaultValue = "1")Integer curr,
+ @RequestParam(defaultValue = "10")Integer limit,
+ @RequestParam(required = false)String orderByField,
+ @RequestParam(required = false)String orderByType,
+ @RequestParam Map<String, Object> param){
+ val id = param.get("id");
+ String uuid=null;
+ if(id!=null){
+ uuid = id.toString();
+ }
+
+ Page<Item> projectPlanPage = itemService.chaoTime(toPage(curr,limit,param,Item.class),uuid);
+ return R.ok(projectPlanPage);
+ }
+
@RequestMapping(value = "/item/add/auth")
@ManagerAuth
public R add(Item item) {
- item.setHostId(getHostId());
+ /**
+ * 鎺х
+ */
+
+ if (Cools.isEmpty(item)) {
+ return R.error("鍙傛暟涓虹┖,璇疯仈绯荤鐞嗗憳");
+ }
+
+ //item.setType("1");
+// if (!item.getType().equals("1")) {
+// throw new CoolException("鐩墠浠呮敮鎸侀泦鎴愰」鐩�");
+// }
+ Item name = itemService.selectOne(new EntityWrapper<Item>()
+ .eq("name", item.getName()));
+ if (!Cools.isEmpty(name)) {
+ 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.getCstmrUuid())));
+ if (Cools.isEmpty(cstmr)) {
+ throw new CoolException("鎵句笉鍒拌瀹㈡埛,璇锋鏌�");
+ }
+ item.setCustMan(cstmr.getName());
+ item.setCustMobile(cstmr.getTel());
+ item.setCustAdress(cstmr.getAddr());
+ 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());
- itemService.insert(item);
+ itemService.insertAll(item);
return R.ok();
}
@RequestMapping(value = "/item/update/auth")
@ManagerAuth
public R update(Item item){
- if (Cools.isEmpty(item) || null==item.getUuid()){
- return R.error();
+ EntityWrapper<Item> wapper = new EntityWrapper<Item>();
+ Item newitem = itemService.selectOne(wapper.eq("id", item.getId()));
+ if (Cools.isEmpty(item)) {
+ return R.error("鍙傛暟涓虹┖,璇疯仈绯荤鐞嗗憳");
+ }
+
+// item.setType("1");
+// if (!item.getType().equals("1")) {
+// throw new CoolException("鐩墠浠呮敮鎸侀泦鎴愰」鐩�");
+// }
+// item.setRealMonth(1);
+// if (item.getRealMonth() < 0){
+// throw new CoolException("瀹炴柦鍛ㄦ湡涓嶅彲涓鸿礋鏁�");
+// }
+
+
+ //鈫撯啌鈫撳啓杩欐浠g爜鐨勭湡璇ユ娊澶у槾宸村瓙
+// 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());
+ }
+ //瓒呭嚭澶╂暟
+ 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());
- itemService.updateById(item);
+ itemService.update(item,new EntityWrapper<Item>()
+ .eq("id",item.getId()));
+// itemService.updateById(item);
return R.ok();
}
@RequestMapping(value = "/item/delete/auth")
@ManagerAuth
- public R delete(@RequestParam String param){
- List<Item> list = JSONArray.parseArray(param, Item.class);
- if (Cools.isEmpty(list)){
- return R.error();
- }
- for (Item entity : list){
- itemService.delete(new EntityWrapper<>(entity));
+ 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));
+// }
+ if (param != null){
+ String[] split = param.split(",");
+ for (String s : split) {
+ Item item = itemService.selectOne(new EntityWrapper<Item>()
+ .eq("id", s));
+ item.setStatus(2);
+ itemService.update(item,new EntityWrapper<Item>()
+ .eq("id",item.getId()));
+ }
}
return R.ok();
}
@@ -135,4 +265,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);
+ }
+
}
--
Gitblit v1.9.1