|
@@ -0,0 +1,401 @@
|
|
|
+package org.jeecg.modules.appInterface.controller;
|
|
|
+
|
|
|
+import java.sql.Connection;
|
|
|
+import java.sql.DriverManager;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URLDecoder;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.system.query.QueryGenerator;
|
|
|
+import org.jeecg.common.util.oConvertUtils;
|
|
|
+import org.jeecg.modules.appInterface.ResHttpStatus;
|
|
|
+import org.jeecg.modules.appInterface.entity.FbsWorkingStatistics;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+
|
|
|
+import org.jeecg.modules.appInterface.service.IFbsWorkingStatisticsService;
|
|
|
+import org.jeecg.modules.fbsWorkshopDispatchList.entity.FbsWorkshopDispatchList;
|
|
|
+import org.jeecg.modules.fbsWorkshopDispatchList.service.IFbsWorkshopDispatchListService;
|
|
|
+import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
+import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
|
+import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
|
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Title: Controller
|
|
|
+ * @Description: 工时统计接口
|
|
|
+ * @author: jeecg-boot
|
|
|
+ * @date: 2020-10-15
|
|
|
+ * @version: V1.0
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/workingStatistics/fbsWorkingStatistics")
|
|
|
+@Slf4j
|
|
|
+public class FbsWorkingStatisticsController {
|
|
|
+ @Autowired
|
|
|
+ private IFbsWorkingStatisticsService fbsWorkingStatisticsService;
|
|
|
+ @Autowired
|
|
|
+ private IFbsWorkshopDispatchListService fbsWorkshopDispatchListService;
|
|
|
+
|
|
|
+ public static void main(String[] srg) {
|
|
|
+ String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
|
|
|
+ //加载JDBC驱动
|
|
|
+ String dbURL = "jdbc:sqlserver://103.40.192.17:43110;DatabaseName=UFDATA_006_2019";
|
|
|
+ //连接服务器和数据库
|
|
|
+ String userName = "sa"; //默认用户名
|
|
|
+ String userPwd = "admin"; //密码
|
|
|
+ Connection dbConn;
|
|
|
+ try {
|
|
|
+ Class.forName(driverName);
|
|
|
+ dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
|
|
|
+ System.out.println("Connection Successful!");
|
|
|
+ //如果连接成功 控制台输出Connection Successful!
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 开工
|
|
|
+ * @param entity
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/startOperation", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseEntity<ResHttpStatus> startOperation(FbsWorkingStatistics entity){
|
|
|
+ ResHttpStatus res = new ResHttpStatus();
|
|
|
+ FbsWorkingStatistics fbsWorkingStatistics = new FbsWorkingStatistics();
|
|
|
+
|
|
|
+ if(entity == null){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("参数不能为空");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(entity.getPersonnelCode())){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("人员编码不能为空");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(entity.getPersonnelName())){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("人员名称不能为空");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(entity.getOrderNumber())){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("订单号不能为空");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(entity.getOrderId())){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("订单id不能为空");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ FbsWorkshopDispatchList workshopDispatchList = fbsWorkshopDispatchListService.getById(entity.getOrderId());
|
|
|
+ if(workshopDispatchList == null){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("该订单还没有派工"+entity.getOrderNumber());
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ //0初始,1接单,2暂停,3完成
|
|
|
+ if(StringUtils.isNotBlank(workshopDispatchList.getState()) && !workshopDispatchList.getState().equals("0") &&
|
|
|
+ !workshopDispatchList.getState().equals("2")){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("该订单已开工或已结束,请勿再次操作"+entity.getOrderNumber());
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ fbsWorkingStatistics.setTimeInfo(new Date());//获取当前时间
|
|
|
+ fbsWorkingStatistics.setFinalInfo("开工");
|
|
|
+ fbsWorkingStatistics.setFinalState("1");//完结状态(1-开工,2-下岗/暂停,3-实时报工)
|
|
|
+
|
|
|
+ fbsWorkingStatisticsService.save(fbsWorkingStatistics);
|
|
|
+ fbsWorkshopDispatchListService.updateState("1",entity.getOrderId());
|
|
|
+
|
|
|
+ res.setCode("0");
|
|
|
+ res.setMsg("成功");
|
|
|
+ res.setData(fbsWorkingStatistics);
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下岗/暂停
|
|
|
+ * @param entity
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/suspendOperation", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseEntity<ResHttpStatus> suspendOperation(FbsWorkingStatistics entity){
|
|
|
+ ResHttpStatus res = new ResHttpStatus();
|
|
|
+ FbsWorkingStatistics fbsWorkingStatistics = new FbsWorkingStatistics();
|
|
|
+
|
|
|
+ if(entity == null){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("参数不能为空");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(entity.getId())){
|
|
|
+ entity.setId(null);
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(entity.getPersonnelCode())){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("人员编码不能为空");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(entity.getPersonnelName())){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("人员名称不能为空");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(entity.getOrderNumber())){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("订单号不能为空");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(entity.getOrderId())){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("订单id不能为空");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ FbsWorkshopDispatchList workshopDispatchList = fbsWorkshopDispatchListService.getById(entity.getOrderId());
|
|
|
+ if(workshopDispatchList == null){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("该订单还没有派工"+entity.getOrderNumber());
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ //状态(0初始,1接单,2暂停,3完成)
|
|
|
+ if(StringUtils.isNotBlank(workshopDispatchList.getState()) && !workshopDispatchList.getState().equals("1")){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("该订单目前不在可暂停状态,无法暂停"+entity.getOrderNumber());
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ fbsWorkingStatistics.setTimeInfo(new Date());//获取当前时间
|
|
|
+ fbsWorkingStatistics.setFinalInfo("下岗/暂停");
|
|
|
+ fbsWorkingStatistics.setFinalState("2");//完结状态(1-开工,2-下岗/暂停,3-实时报工)
|
|
|
+ fbsWorkingStatisticsService.save(fbsWorkingStatistics);
|
|
|
+ fbsWorkshopDispatchListService.updateState("2",entity.getOrderId());
|
|
|
+
|
|
|
+ res.setCode("0");
|
|
|
+ res.setMsg("成功");
|
|
|
+ res.setData(fbsWorkingStatistics);
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 实时报工
|
|
|
+ * @param entity
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/finishDoing", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseEntity<ResHttpStatus> finishDoing(FbsWorkingStatistics entity){
|
|
|
+ ResHttpStatus res = new ResHttpStatus();
|
|
|
+ FbsWorkingStatistics fbsWorkingStatistics = new FbsWorkingStatistics();
|
|
|
+
|
|
|
+ if(entity == null){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("参数不能为空 ");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(entity.getId())){
|
|
|
+ entity.setId(null);
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(entity.getPersonnelCode())){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("人员编码不能为空");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(entity.getPersonnelName())){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("人员名称不能为空");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(entity.getOrderNumber())){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("订单号不能为空");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(entity.getOrderId())){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("订单id不能为空");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ FbsWorkshopDispatchList workshopDispatchList = fbsWorkshopDispatchListService.getById(entity.getOrderId());
|
|
|
+ if(workshopDispatchList == null){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("该订单还没有派工"+entity.getOrderNumber());
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ //状态(0初始,1接单,2暂停,3完成)
|
|
|
+ if(StringUtils.isNotBlank(workshopDispatchList.getState()) && !workshopDispatchList.getState().equals("1")){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("该订单目前正在进行中,无法报工"+entity.getOrderNumber());
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ fbsWorkingStatistics.setFinalInfo("实时报工");
|
|
|
+ fbsWorkingStatistics.setFinalState("3");//完结状态(1-开工,2-下岗/暂停,3-实时报工)
|
|
|
+ fbsWorkingStatisticsService.save(fbsWorkingStatistics);
|
|
|
+ fbsWorkshopDispatchListService.updateState("3",entity.getOrderId());
|
|
|
+
|
|
|
+ res.setCode("0");
|
|
|
+ res.setMsg("成功");
|
|
|
+ res.setData(fbsWorkingStatistics);
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页列表查询
|
|
|
+ * @param fbsWorkingStatistics
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/list")
|
|
|
+ public Result<IPage<FbsWorkingStatistics>> queryPageList(FbsWorkingStatistics fbsWorkingStatistics,
|
|
|
+ @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ Result<IPage<FbsWorkingStatistics>> result = new Result<IPage<FbsWorkingStatistics>>();
|
|
|
+ QueryWrapper<FbsWorkingStatistics> queryWrapper = QueryGenerator.initQueryWrapper(fbsWorkingStatistics, req.getParameterMap());
|
|
|
+ Page<FbsWorkingStatistics> page = new Page<FbsWorkingStatistics>(pageNo, pageSize);
|
|
|
+ IPage<FbsWorkingStatistics> pageList = fbsWorkingStatisticsService.page(page, queryWrapper);
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(pageList);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ * @param fbsWorkingStatistics
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/add")
|
|
|
+ public Result<FbsWorkingStatistics> add(@RequestBody FbsWorkingStatistics fbsWorkingStatistics) {
|
|
|
+ Result<FbsWorkingStatistics> result = new Result<FbsWorkingStatistics>();
|
|
|
+ try {
|
|
|
+ fbsWorkingStatisticsService.save(fbsWorkingStatistics);
|
|
|
+ result.success("添加成功!");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.info(e.getMessage());
|
|
|
+ result.error500("操作失败");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ * @param fbsWorkingStatistics
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PutMapping(value = "/edit")
|
|
|
+ public Result<FbsWorkingStatistics> edit(@RequestBody FbsWorkingStatistics fbsWorkingStatistics) {
|
|
|
+ Result<FbsWorkingStatistics> result = new Result<FbsWorkingStatistics>();
|
|
|
+ FbsWorkingStatistics fbsWorkingStatisticsEntity = fbsWorkingStatisticsService.getById(fbsWorkingStatistics.getId());
|
|
|
+ if(fbsWorkingStatisticsEntity==null) {
|
|
|
+ result.error500("未找到对应实体");
|
|
|
+ }else {
|
|
|
+ boolean ok = fbsWorkingStatisticsService.updateById(fbsWorkingStatistics);
|
|
|
+ //TODO 返回false说明什么?
|
|
|
+ if(ok) {
|
|
|
+ result.success("修改成功!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id删除
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @DeleteMapping(value = "/delete")
|
|
|
+ public Result<FbsWorkingStatistics> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
+ Result<FbsWorkingStatistics> result = new Result<FbsWorkingStatistics>();
|
|
|
+ FbsWorkingStatistics fbsWorkingStatistics = fbsWorkingStatisticsService.getById(id);
|
|
|
+ if(fbsWorkingStatistics==null) {
|
|
|
+ result.error500("未找到对应实体");
|
|
|
+ }else {
|
|
|
+ boolean ok = fbsWorkingStatisticsService.removeById(id);
|
|
|
+ if(ok) {
|
|
|
+ result.success("删除成功!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @DeleteMapping(value = "/deleteBatch")
|
|
|
+ public Result<FbsWorkingStatistics> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
+ Result<FbsWorkingStatistics> result = new Result<FbsWorkingStatistics>();
|
|
|
+ if(ids==null || "".equals(ids.trim())) {
|
|
|
+ result.error500("参数不识别!");
|
|
|
+ }else {
|
|
|
+ this.fbsWorkingStatisticsService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
+ result.success("删除成功!");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/queryById")
|
|
|
+ public Result<FbsWorkingStatistics> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
+ Result<FbsWorkingStatistics> result = new Result<FbsWorkingStatistics>();
|
|
|
+ FbsWorkingStatistics fbsWorkingStatistics = fbsWorkingStatisticsService.getById(id);
|
|
|
+ if(fbsWorkingStatistics==null) {
|
|
|
+ result.error500("未找到对应实体");
|
|
|
+ }else {
|
|
|
+ result.setResult(fbsWorkingStatistics);
|
|
|
+ result.setSuccess(true);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|