| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511 |
- package com.goafanti.weChat.controller;
- import com.goafanti.common.bo.Error;
- import com.goafanti.common.bo.Result;
- import com.goafanti.common.constant.ErrorConstants;
- import com.goafanti.common.controller.CertifyApiController;
- import com.goafanti.common.error.BusinessException;
- import com.goafanti.common.utils.StringUtils;
- import com.goafanti.common.utils.excel.NewExcelUtil;
- import com.goafanti.weChat.bo.*;
- import com.goafanti.weChat.service.PublicReleaseService;
- import org.apache.commons.beanutils.BeanUtils;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.util.ArrayList;
- import java.util.List;
- @RestController
- @RequestMapping(value = "/api/admin/release")
- public class AdminReleaseApiController extends CertifyApiController{
- @Resource
- private PublicReleaseService publicReleaseService;
- @Value(value = "${upload.path}")
- private String uploadPath = null;
- /**
- * 发起外出申请、发起公出
- */
- @RequestMapping(value = "/addPublicRelease", method = RequestMethod.POST)
- public Result addPublicRelease(InputPublicRelease in){
- Result res = new Result();
- if (StringUtils.isBlank(in.getUids())) {
- res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"用户编号"));
- return res;
- }
- if (StringUtils.isBlank(in.getReleaseStarts())) {
- res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"公出时间"));
- return res;
- }
- if (StringUtils.isBlank(in.getDistrictName())) {
- res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"公出地点"));
- return res;
- }
- if (publicReleaseService.checkTime(in)) {
- res.getError().add(buildError("公出时段已经被使用!","公出时段已经被使用!"));
- return res;
- }
- if(in.getAssist()==null)in.setAssist(0);
- if (in.getAssist()==1&&in.getAssistAid()==null) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"协单人员"));
- return res;
- }
- res.setData(publicReleaseService.addPublicRelease(in));
- return res;
- }
- /**
- * 修改外出申请、修改公出
- */
- @RequestMapping(value = "/updatePublicRelease", method = RequestMethod.POST)
- public Result updatePublicRelease(InputPublicRelease in){
- Result res = new Result();
- if (in.getId()==null){
- res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"编号"));
- return res;
- }
- if (in.getStatus()!=3&&publicReleaseService.checkTime(in)) {
- res.getError().add(buildError("公出时段已经被使用!","公出时段已经被使用!"));
- return res;
- }
- res.setData(publicReleaseService.updatePublicRelease(in));
- return res;
- }
- /**
- * 修改打卡地址
- */
- @RequestMapping(value = "/updateLocation", method = RequestMethod.POST)
- public Result updateLocation(InputPublicRelease in){
- Result res = new Result();
- if (in.getId()==null||in.getUid()==null){
- res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"编号"));
- return res;
- }
- if (in.getLatitude()==null||in.getLongitude()==null||in.getDistrictName()==null){
- res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"位置"));
- return res;
- }
- res.setData(publicReleaseService.updateLocation(in));
- return res;
- }
- /**
- * 外出打卡、公出打卡
- */
- @RequestMapping(value = "/publicReleaseClockIn", method = RequestMethod.POST)
- public Result publicReleaseClockIn(Integer id,String photoUrl,Integer clockIn ,String clockInRemarks,String uid ){
- Result res =new Result();
- int x=publicReleaseService.pushPublicReleaseClockIn(id,photoUrl,clockIn,clockInRemarks,uid);
- if (x==-1){
- res.getError().add(buildError("公出他人企业!需通过审核,才可以打卡!"));
- return res;
- }
- // 取消打卡限制
- if (x==-2){
- res.getError().add(buildError("公出审核中,不可打卡!"));
- return res;
- }
- if (x==-3){
- res.getError().add(buildError("技术协单,必须先写协单意见,才可打卡!"));
- return res;
- }
- res.setData(x);
- return res;
- }
- /**
- * 外出申请详情
- */
- @RequestMapping(value = "/dtails", method = RequestMethod.GET)
- public Result dtails(Integer id){
- Result res =new Result();
- res.setData(publicReleaseService.dtails(id));
- return res;
- }
- /**
- * 外出申请详情
- */
- @RequestMapping(value = "/followDtails", method = RequestMethod.GET)
- public Result followDtails(String id){
- Result res =new Result();
- res.setData(publicReleaseService.followDtails(id));
- return res;
- }
- /**
- * 外出申请列表.公出列表,我的协单列表,协单审核
- */
- @RequestMapping(value = "/listPublicRelease", method = RequestMethod.GET)
- public Result listPublicRelease(InputPublicReleaseList in){
- Result res =new Result();
- res.setData(publicReleaseService.listPublicRelease(in));
- return res;
- }
- /**
- * 公出审核、外出审核 上级
- */
- @RequestMapping(value = "/examinePublicRelease", method = RequestMethod.POST)
- public Result examinePublicRelease(Integer id ,Integer status,String remarks){
- Result res =new Result();
- if (id==null) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
- return res;
- }
- if (status!=0&&status!=2) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"审核状态"));
- return res;
- }
- if (remarks.length()>20) {
- res.getError().add(buildError("备注长度不能超过20个字符。"));
- return res;
- }
- res.setData(publicReleaseService.pushExaminePublicRelease(id,status,remarks,0));
- return res;
- }
- /**
- * 公出审核、外出审核 营销
- */
- @RequestMapping(value = "/marketersExamine", method = RequestMethod.POST)
- public Result marketersExamine(Integer id ,Integer status,String remarks){
- Result res =new Result();
- if (id==null) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
- return res;
- }
- if (status!=0&&status!=2) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"审核状态"));
- return res;
- }
- if (remarks.length()>20) {
- res.getError().add(buildError("备注长度不能超过20个字符。"));
- return res;
- }
- res.setData(publicReleaseService.pushExaminePublicRelease(id,status,remarks,1));
- return res;
- }
- /**
- * 公出审核、外出审核 协单审核
- */
- @RequestMapping(value = "/assistExamine", method = RequestMethod.POST)
- public Result assistExamine(Integer id ,Integer status,String remarks){
- Result res =new Result();
- if (id==null) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
- return res;
- }
- if (status!=0&&status!=2) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"审核状态"));
- return res;
- }
- if (remarks.length()>20) {
- res.getError().add(buildError("备注长度不能超过20个字符。"));
- return res;
- }
- res.setData(publicReleaseService.updateAssistExamine(id,status,remarks));
- return res;
- }
- @RequestMapping(value = "/techExamine", method = RequestMethod.POST)
- public Result techExamine(Integer id ,Integer status,String remarks){
- Result res =new Result();
- if (id==null) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
- return res;
- }
- if (status!=0&&status!=2) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"审核状态"));
- return res;
- }
- if (remarks.length()>20) {
- res.getError().add(buildError("备注长度不能超过20个字符。"));
- return res;
- }
- res.setData(publicReleaseService.pushExaminePublicRelease(id,status,remarks,2));
- return res;
- }
- /**
- * 咨询驳回
- */
- @RequestMapping(value = "/techReject", method = RequestMethod.POST)
- public Result techReject(Integer id ,String remarks){
- Result res =new Result();
- if (id==null) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
- return res;
- }
- if (remarks.length()>20) {
- res.getError().add(buildError("备注长度不能超过20个字符。"));
- return res;
- }
- res.setData(publicReleaseService.pushTechReject( id , remarks));
- return res;
- }
- /**
- * 外出审核日志列表
- */
- @RequestMapping(value = "/listPublicReleaseLog", method = RequestMethod.GET)
- public Result listPublicReleaseLog(Integer id,String ufid){
- Result res =new Result();
- res.data(publicReleaseService.listPublicReleaseLog(id,ufid));
- return res;
- }
- /**
- * 公出统计
- */
- @RequestMapping(value = "/publicReleaseStatistics", method = RequestMethod.GET)
- public Result publicReleaseStatistics(InputPublicStatistics in){
- Result res =new Result();
- res.data(publicReleaseService.publicReleaseStatistics(in));
- return res;
- }
- /**
- * 公出统计导出
- */
- @RequestMapping(value = "/publicReleaseStatistics/export", method = RequestMethod.GET)
- public Result publicReleaseStatisticsExport(InputPublicStatistics in,HttpServletResponse response){
- List<OutPublicStatistics> list =publicReleaseService.publicReleaseStatisticsList(in);
- NewExcelUtil<OutPublicStatistics>excel=new NewExcelUtil<>(OutPublicStatistics.class);
- return excel.exportExcel(list,"公出统计列表",response);
- }
- /**
- * 公出详情列表
- */
- @RequestMapping(value = "/publicReleaseDtails", method = RequestMethod.GET)
- public Result publicReleaseListDtails(InputPublicDtails in){
- Result res =new Result();
- res.data(publicReleaseService.publicReleaseListDtails(in));
- return res;
- }
- @RequestMapping(value = "/publicReleaseAndCount", method = RequestMethod.GET)
- public Result publicReleaseAndCount(InputPublicDtails in){
- Result res =new Result();
- res.data(publicReleaseService.publicReleaseAndCount(in));
- return res;
- }
- /**
- * 公出详情列表
- */
- @RequestMapping(value = "/publicReleaseDtails/export", method = RequestMethod.GET)
- public Result publicReleaseListDtailsExport(InputPublicDtails in ,Integer exportType){
- if (exportType==null)exportType=0;
- List<OutPublicDtails> outList=publicReleaseService.publicReleaseListDtailsList(in);
- publicReleaseService.pushOutPublicDtails(outList);
- if (exportType==0){
- NewExcelUtil<OutPublicDtails>excel=new NewExcelUtil<>(OutPublicDtails.class);
- return excel.exportExcel(outList,"公出详细列表",uploadPath);
- }else if (exportType==1){
- List<OutPublicDtailsFinance> list = new ArrayList<>();
- for (OutPublicDtails outPublicDtails : outList) {
- OutPublicDtailsFinance of= new OutPublicDtailsFinance();
- try {
- BeanUtils.copyProperties( of,outPublicDtails);
- } catch (Exception e) {
- throw new BusinessException("数据转换异常");
- }
- list.add(of);
- }
- NewExcelUtil<OutPublicDtailsFinance>excel=new NewExcelUtil<>(OutPublicDtailsFinance.class);
- return excel.exportExcel(list,"公出详细列表",uploadPath);
- }
- return null;
- }
- /** 上传图片 **/
- @RequestMapping(value = "/upload", method = RequestMethod.POST)
- public Result uploadOrderInvoiceFile(HttpServletRequest req){
- Result res = new Result();
- res.setData(handleFile(res, "/publicRelease/", false, req, "publicRelease"));
- return res;
- }
- /**
- * 搜索
- */
- @RequestMapping(value = "/addSupplement", method = RequestMethod.POST)
- public Result addSupplement(Integer id,String supplement,String nextPlan){
- Result res =new Result();
- if (id==null) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号"));
- return res;
- }
- if (supplement==null) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"本次公出目标总结"));
- return res;
- }
- if (nextPlan==null) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"下次公出计划"));
- return res;
- }
- res.setData(publicReleaseService.addSupplement( id ,supplement,nextPlan));
- return res;
- }
- /**
- * 根据客户返回订单
- */
- @RequestMapping(value = "/selectOrderByUid",method =RequestMethod.GET)
- public Result selectOrderByUid(String uid){
- Result res = new Result();
- if (uid==null){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,ErrorConstants.PARAM_EMPTY_ERROR,"客户编号"));
- return res;
- }
- res.data(publicReleaseService.selectOrderByUid(uid));
- return res;
- }
- /**
- * 查看上门记录
- */
- @RequestMapping(value = "/publicByOrder",method =RequestMethod.GET)
- public Result publicByOrder(String orderNo){
- Result res = new Result();
- if (orderNo==null){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,ErrorConstants.PARAM_EMPTY_ERROR,"订单编号"));
- return res;
- }
- res.data(publicReleaseService.publicByOrder(orderNo));
- return res;
- }
- /**
- * 打卡页面获取自己最新的打卡
- */
- @RequestMapping(value = "/getMyNewPublic",method = RequestMethod.GET)
- public Result getMyNewPublic (){
- Result res =new Result();
- res.data(publicReleaseService.getMyNewPublic());
- return res;
- }
- /**
- * 新增协单助手
- * @param id 公出编号
- * @param aid 协单助手编号
- */
- @RequestMapping(value = "/addAssistant",method = RequestMethod.POST)
- public Result addAssistant (Integer id,String aid){
- Result res =new Result();
- if (id==null||aid==null){
- res.getError().add(new Error(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号与人员编号"));
- return res;
- }
- if (publicReleaseService.checkaddAssistant(id,aid)){
- res.getError().add(new Error("协单助手已经存在"));
- return res;
- }
- res.data(publicReleaseService.addAssistant(id,aid));
- return res;
- }
- /**
- * 删除协单助手
- * @param id 公出编号
- * @param aid 协单助手编号
- */
- @RequestMapping(value = "/deleteAssistant",method = RequestMethod.POST)
- public Result deleteAssistant (Integer id,String aid){
- Result res =new Result();
- if (id==null||aid==null){
- res.getError().add(new Error(ErrorConstants.PARAM_EMPTY_ERROR,"公出编号与人员编号"));
- return res;
- }
- if (publicReleaseService.checkdeleteAssistant(id,aid)){
- res.getError().add(new Error("协单助手已经打卡,无法删除"));
- return res;
- }
- res.data(publicReleaseService.deleteAssistant(id,aid));
- return res;
- }
- /**
- * 技术发起公出查询发起情况
- */
- @RequestMapping(value = "/checkOrderNoDuration",method = RequestMethod.GET)
- public Result checkOrderNoDuration (InputPublicRelease in){
- Result res =new Result();
- return res.data(publicReleaseService.checkOrderNoDuration(in));
- }
- /**
- * 技术发起公出查询发起情况
- */
- @RequestMapping(value = "/pushDateClock",method = RequestMethod.POST)
- public Result pushDateClock (){
- Result res =new Result();
- return res.data(publicReleaseService.pushDateClock());
- }
- /**
- * 公出&报销表
- */
- @RequestMapping(value = "/releaseAndExpenseCount",method = RequestMethod.GET)
- public Result releaseAndExpenseCount (InputreleaseAndExpenseCount in){
- Result res =new Result();
- return res.data(publicReleaseService.releaseAndExpenseCount(in));
- }/**
- * 公出&报销缓存清除
- */
- @RequestMapping(value = "/releaseAndExpenseCountClear",method = RequestMethod.GET)
- public Result releaseAndExpenseCountClear (){
- Result res =new Result();
- return res.data(publicReleaseService.releaseAndExpenseCountClear());
- }
- /**
- * 公出&报销表导出
- */
- @RequestMapping(value = "/releaseAndExpenseCount/Export",method = RequestMethod.GET)
- public Result releaseAndExpenseCountExport (InputreleaseAndExpenseCount in){
- List<releaseAndExpenseCountOut> list = publicReleaseService.releaseAndExpenseCount(in);
- NewExcelUtil<releaseAndExpenseCountOut> excelUtil=new NewExcelUtil<>(releaseAndExpenseCountOut.class);
- return excelUtil.exportExcel(list,"公出与报销表",uploadPath);
- }
- /**
- * 协单审核是否有未审核查询
- */
- @RequestMapping(value = "/unaudited",method = RequestMethod.GET)
- public Result assistUnaudited (){
- Result res =new Result();
- return res.data(publicReleaseService.assistUnaudited());
- }
- }
|